Big Modular Exponentiation

Today’s exercise is a frequent source of questions at places like Stack Overflow and /r/learnprogramming; it must come from one of the competitive programming sites like SPOJ or UVA. The most common statement of the problem is something like this: You are given two positive integers P and Q, either of which can be quite … Continue reading Big Modular Exponentiation