using System.Collections.Generic;
public static int ComputePowerFnRecursively(int A, int B, int C){
answer = Program.ComputePowerFnRecursively(A, (B / 2), C) % C;
answer = (answer * answer) % C;
answer = (answer * Program.ComputePowerFnRecursively(A, (B - 1), C) % C) % C;
return (int)((answer + C) % C);
public static void Main()
int PowerValue = Program.ComputePowerFnRecursively(A, B, C);
Console.WriteLine("The Power Value is : " + PowerValue);