Periodic modular exponentiation (source code)

= Periodic modular exponentiation

For a unit $a$ modulo $N$, the function $x\mapsto a^x\bmod N$ is periodic on the integers.