Answer = pow(A, B)


#1

Don’t use the in-built function.
Create your own power function and use mod at each step.
Running time should be log(B).
For more, search “Modular Exponentiation”.