Erwin Janssen

Euler’s theorem

By Erwin Janssen

Euler’s theorem may be used to compute modular inverses. According to the theorem, if aa is coprime to mm, that is, gcd(a,m)=1\gcd(a, m) = 1, then

aφ(m)1(modm) a^{\varphi(m)} \equiv 1 \pmod{m}

where φ\varphi is Euler’s totient function. A modular multiplicative inverse can be found directly with:

aφ(m)1a1(modm) a^{\varphi(m) - 1} \equiv a^{-1} \pmod{m}

Computing aφ(m)1a^{\varphi(m) - 1} can be done using modular exponentiation.