📅  最后修改于: 2022-03-11 14:57:31.950000             🧑  作者: Mango
int binaryExponentiation(int x,int n)
{
if(n==0)
return 1;
else if(n%2 == 0) //n is even
return binaryExponentiation(x*x,n/2);
else //n is odd
return x*binaryExponentiation(x*x,(n-1)/2);
}