How to calculate modulus of large numbers?
Okay, so you want to calculate a^b mod m. First we’ll take a naive approach and then see how we can refine it. First, reduce a mod m. That means, find a number a1 so that 0 <= a1 < m and a = a1 mod m. Then repeatedly in a loop multiply by a1 … Read more