modPow function
Implementation
int modPow(int base, int exp, int modulus) {
int result = 1;
int cur = base;
int e = exp;
while (e > 0) {
if ((e & 1) != 0) {
result = modMul(result, cur, modulus);
}
cur = modMul(cur, cur, modulus);
e >>= 1;
}
return result;
}