Compute: a^{b} mod n, where a and b are nonnegative integers and n is a positive integer.

Let .

Compute a^{c} mod n by doubling c for each i and incrementing c when b_{i}= 1.