How exactly does the pow built-in function in python work? Specifically, how does it compute (a^b)%c. What is the algorithm?
>>>pow(134562,12345,15)
12
whereas the naive,
>>>(134562**12345)%15
isn't able to yield anything even after a significant amount of time. What optimisation is performed that leads to the massive speed up?