After compiling the entire code, this is the error i got:
[Error] invalid operands of types '__gnu_cxx::__promote_2<int, int, double, double>::__type {aka double}' and 'int' to binary 'operator%'
I have tried type casting for n/2 to int
in the last line of the code but still showed the same error:
int rem(int n,int b,int d)
{
if(n==1)
{
return b%d;
}
else
{
return (pow(rem(n/2,b,d),2)%d);
}
}