Two classical theorems are the arithmetic heart of RSA: Fermat’s one for prime moduli and its generalisation due to Euler for arbitrary moduli.

Theorem — Fermat's little theorem

If pp is prime and mcd(a,p)=1\mathrm{mcd}(a,p)=1, then ap11(modp).a^{p-1} \equiv 1\pmod p.

Theorem — Euler

Let φ(n)\varphi(n) be the number of integers in {1,2,,n}\{1,2,\ldots,n\} coprime with nn (Euler’s totient function). If mcd(a,n)=1\mathrm{mcd}(a,n)=1, then aφ(n)1(modn).a^{\varphi(n)} \equiv 1\pmod n.

For a historical re-reading of Fermat and Euler on modular residues see Stillwell (ch. 3).

Computing φ(n)\varphi(n). If n=pqn = p\cdot q with p,qp,q distinct primes, φ(n)=(p1)(q1)\varphi(n) = (p-1)(q-1). Example: φ(1113)=1012=120\varphi(11\cdot 13) = 10\cdot 12 = 120.

Topics: Distribuzioni probabilita
Concepts: Aritmetica modulare · Funzione di eulero
Skills: Usare formule
People: Leonhard Euler (Eulero) · Pierre de Fermat