Euler's Totient Function and Euler's Theorem

  • ϕ(n)\phi(n) counts positive integers ≤ nn that are coprime to nn (share no common factors except 1)
  • Euler's Theorem: if gcd⁡(a,n)=1\gcd(a,n)=1, then aϕ(n)≡1(modn)a^{\phi(n)} \equiv 1 \pmod{n} generalizes Fermat's Little Theorem
  • ϕ(n)\phi(n) measures the exponent of periodicity in modular arithmetic—how many multiplications until cycling back to 1
  • For prime factorization n=p1k1⋯prkrn = p_1^{k_1} \cdots p_r^{k_r}: ϕ(n)=n∏(1−1/pi)\phi(n) = n\prod(1 - 1/p_i) over prime divisors
  • Central to RSA cryptosystem security; transforms number theory from isolated results into coherent predictive theory
  • The multiplicative group modulo nn has order ϕ(n)\phi(n), linking counting to group structure

Euler's Totient Function and Euler's Theorem

Overview

Euler's Totient Function, denoted ϕ(n)\phi(n), counts how many positive integers up to nn are relatively prime to nn—that is, share no common factors with nn except 1. This seemingly simple counting question turns out to be one of the most fundamental objects in number theory, connecting divisibility, modular arithmetic, prime factorization, and the structure of multiplicative groups. The totient function appears throughout modern mathematics and computer science, from cryptography to abstract algebra, making it essential knowledge for any student of pure or applied mathematics. The power of the totient function becomes fully apparent through Euler's Theorem, which generalizes Fermat's Little Theorem and provides a deep connection between counting and congruences. Euler's Theorem states that if aa and nn are coprime, then aϕ(n)≡1(modn)a^{\phi(n)} \equiv 1 \pmod{n}. This elegant result reveals that the totient function measures the exponent of periodicity in modular arithmetic—it tells us exactly how far we need to raise numbers before they cycle back to 1 modulo nn. Leonhard Euler introduced both the totient function and his theorem in the 1760s, building on Fermat's work from a century earlier. These contributions transformed number theory from a collection of isolated observations into a coherent theory with predictive power. The totient function would later prove central to the RSA cryptosystem, making it one of the rare mathematical concepts that directly protects digital communications worldwide.

💡 The Core Insight

The totient function ϕ(n)\phi(n) counts coprime residues and simultaneously reveals the multiplicative order structure modulo nn: every number coprime to nn returns to 1 after exactly ϕ(n)\phi(n) multiplications.

Definition

Euler's Totient Function: For a positive integer nn, the Euler totient function (or Euler phi function) is defined as

ϕ(n)=∣{k∈Z:1≤k≤n and gcd⁡(k,n)=1}∣\phi(n) = |\{k \in \mathbb{Z} : 1 \leq k \leq n \text{ and } \gcd(k,n) = 1\}|

That is, ϕ(n)\phi(n) counts the number of integers between 1 and nn (inclusive) that are relatively prime to nn.

Euler's Theorem: If nn is a positive integer and aa is an integer with gcd⁡(a,n)=1\gcd(a,n) = 1, then

aϕ(n)≡1(modn)a^{\phi(n)} \equiv 1 \pmod{n}

Core Theory

TheoremMain Results

Theorem 1 (Multiplicativity of ϕ\phi): If gcd⁡(m,n)=1\gcd(m,n) = 1, then ϕ(mn)=ϕ(m)ϕ(n)\phi(mn) = \phi(m)\phi(n).

Theorem 2 (Explicit Formula): If n=p1a1p2a2⋯pkakn = p_1^{a_1} p_2^{a_2} \cdots p_k^{a_k} is the prime factorization of nn, then

ϕ(n)=n∏p∣n(1−1p)=n(1−1p1)(1−1p2)⋯(1−1pk)\phi(n) = n \prod_{p | n} \left(1 - \frac{1}{p}\right) = n \left(1 - \frac{1}{p_1}\right)\left(1 - \frac{1}{p_2}\right) \cdots \left(1 - \frac{1}{p_k}\right)

Theorem 3 (Euler's Theorem): If gcd⁡(a,n)=1\gcd(a,n) = 1, then aϕ(n)≡1(modn)a^{\phi(n)} \equiv 1 \pmod{n}.

Theorem 4 (Prime Power Formula): For a prime pp and positive integer kk,

ϕ(pk)=pk−pk−1=pk−1(p−1)\phi(p^k) = p^k - p^{k-1} = p^{k-1}(p-1)
Proof

Proof of Theorem 4: Among the integers 1,2,3,…,pk1, 2, 3, \ldots, p^k, exactly those that are multiples of pp share a common factor with pkp^k. The multiples of pp in this range are p,2p,3p,…,pk−1⋅pp, 2p, 3p, \ldots, p^{k-1} \cdot p, of which there are pk−1p^{k-1}. Therefore,

ϕ(pk)=pk−pk−1=pk−1(p−1)\phi(p^k) = p^k - p^{k-1} = p^{k-1}(p-1)

Proof of Theorem 1: We use the Chinese Remainder Theorem. Since gcd⁡(m,n)=1\gcd(m,n) = 1, the map

f:Z/mnZ→Z/mZ×Z/nZf: \mathbb{Z}/mn\mathbb{Z} \to \mathbb{Z}/m\mathbb{Z} \times \mathbb{Z}/n\mathbb{Z}

given by f(x  mn)=(x  m,x  n)f(x \bmod mn) = (x \bmod m, x \bmod n) is a ring isomorphism. An element xx is coprime to mnmn if and only if xx is coprime to both mm and nn. Under the isomorphism ff, the units modulo mnmn correspond exactly to pairs (u,v)(u,v) where uu is a unit modulo mm and vv is a unit modulo nn. There are ϕ(m)\phi(m) choices for uu and ϕ(n)\phi(n) choices for vv, giving ϕ(mn)=ϕ(m)ϕ(n)\phi(mn) = \phi(m)\phi(n).

Proof of Theorem 2: By Theorem 1, ϕ\phi is multiplicative, so

ϕ(n)=ϕ(p1a1)ϕ(p2a2)⋯ϕ(pkak)\phi(n) = \phi(p_1^{a_1}) \phi(p_2^{a_2}) \cdots \phi(p_k^{a_k})

By Theorem 4, ϕ(piai)=piai(1−1pi)\phi(p_i^{a_i}) = p_i^{a_i}\left(1 - \frac{1}{p_i}\right). Therefore,

ϕ(n)=∏i=1kpiai(1−1pi)=(∏i=1kpiai)∏i=1k(1−1pi)=n∏p∣n(1−1p)\phi(n) = \prod_{i=1}^k p_i^{a_i}\left(1 - \frac{1}{p_i}\right) = \left(\prod_{i=1}^k p_i^{a_i}\right) \prod_{i=1}^k \left(1 - \frac{1}{p_i}\right) = n \prod_{p|n}\left(1 - \frac{1}{p}\right)

Proof of Theorem 3 (Euler's Theorem): Let Un={a∈Z:1≤a≤n,gcd⁡(a,n)=1}U_n = \{a \in \mathbb{Z} : 1 \leq a \leq n, \gcd(a,n) = 1\} be the set of reduced residues modulo nn. Then ∣Un∣=ϕ(n)|U_n| = \phi(n).

Claim: If gcd⁡(a,n)=1\gcd(a,n) = 1 and r∈Unr \in U_n, then ar  n∈Unar \bmod n \in U_n. Proof of claim: If d=gcd⁡(ar,n)d = \gcd(ar, n), then d∣ard | ar and d∣nd | n. Since gcd⁡(a,n)=1\gcd(a,n) = 1, any common divisor of arar and nn must also divide rr. Thus d∣gcd⁡(r,n)=1d | \gcd(r,n) = 1, so gcd⁡(ar,n)=1\gcd(ar,n) = 1. Now consider the set {ar  n:r∈Un}\{ar \bmod n : r \in U_n\}. By the claim, each element is in UnU_n. Moreover, if ar1≡ar2(modn)ar_1 \equiv ar_2 \pmod{n}, then since gcd⁡(a,n)=1\gcd(a,n) = 1, we can cancel aa to get r1≡r2(modn)r_1 \equiv r_2 \pmod{n}. Thus multiplication by aa gives a bijection Un→UnU_n \to U_n. Let Un={r1,r2,…,rϕ(n)}U_n = \{r_1, r_2, \ldots, r_{\phi(n)}\}. Then {ar1,ar2,…,arϕ(n)}\{ar_1, ar_2, \ldots, ar_{\phi(n)}\} is a permutation of UnU_n modulo nn. Therefore,

(ar1)(ar2)⋯(arϕ(n))≡r1r2⋯rϕ(n)(modn)(ar_1)(ar_2) \cdots (ar_{\phi(n)}) \equiv r_1 r_2 \cdots r_{\phi(n)} \pmod{n}
aϕ(n)(r1r2⋯rϕ(n))≡r1r2⋯rϕ(n)(modn)a^{\phi(n)} (r_1 r_2 \cdots r_{\phi(n)}) \equiv r_1 r_2 \cdots r_{\phi(n)} \pmod{n}

Let R=r1r2⋯rϕ(n)R = r_1 r_2 \cdots r_{\phi(n)}. Since each rir_i is coprime to nn, we have gcd⁡(R,n)=1\gcd(R, n) = 1. Therefore, we can cancel RR from both sides:

aϕ(n)≡1(modn)a^{\phi(n)} \equiv 1 \pmod{n}

□

∎
⚠️ Common mistake

Common Error: Students often try to apply Euler's Theorem without checking that gcd⁡(a,n)=1\gcd(a,n) = 1. For example, 2ϕ(6)=22=4≢1(mod6)2^{\phi(6)} = 2^2 = 4 \not\equiv 1 \pmod{6} because gcd⁡(2,6)=2≠1\gcd(2,6) = 2 \neq 1. The coprimality condition is essential—the theorem simply doesn't hold otherwise. Similarly, ϕ(n)\phi(n) is not the number of primes less than nn (that's the prime counting function π(n)\pi(n)).

mathematician

Leonhard Euler (1763) — Introduced the totient function and proved Euler's Theorem in his paper "Theoremata arithmetica nova methodo demonstrata," generalizing Fermat's work and founding modern multiplicative number theory.

visualization

φ(12) = 4: Reduced Residues Modulo 12 0 1 2 3 4 5 6 7 8 9 10 11 gcd(k,12)=1 gcd(k,12)>1 12 = 2² × 3

Examples and Applications

Example1

Computing ϕ(360)\phi(360) using the explicit formula: First, find the prime factorization: 360=23⋅32⋅5360 = 2^3 \cdot 3^2 \cdot 5. Using Theorem 2:

ϕ(360)=360(1−12)(1−13)(1−15)\phi(360) = 360 \left(1 - \frac{1}{2}\right)\left(1 - \frac{1}{3}\right)\left(1 - \frac{1}{5}\right)
=360⋅12⋅23⋅45= 360 \cdot \frac{1}{2} \cdot \frac{2}{3} \cdot \frac{4}{5}
=360⋅830=360⋅415=96= 360 \cdot \frac{8}{30} = 360 \cdot \frac{4}{15} = 96

We can verify using multiplicativity:

ϕ(360)=ϕ(23)⋅ϕ(32)⋅ϕ(5)=(22⋅1)⋅(3⋅2)⋅(4)=4⋅6⋅4=96\phi(360) = \phi(2^3) \cdot \phi(3^2) \cdot \phi(5) = (2^2 \cdot 1) \cdot (3 \cdot 2) \cdot (4) = 4 \cdot 6 \cdot 4 = 96

Therefore, there are exactly 96 integers between 1 and 360 that share no common factors with 360.

Example2

Using Euler's Theorem to find 7222  107^{222} \bmod 10: First, check: gcd⁡(7,10)=1\gcd(7, 10) = 1 ✓ Compute ϕ(10)=ϕ(2⋅5)=ϕ(2)ϕ(5)=1⋅4=4\phi(10) = \phi(2 \cdot 5) = \phi(2)\phi(5) = 1 \cdot 4 = 4. By Euler's Theorem, 74≡1(mod10)7^4 \equiv 1 \pmod{10}. Now divide the exponent: 222=4⋅55+2222 = 4 \cdot 55 + 2. Therefore,

7222=74⋅55+2=(74)55⋅72≡155⋅49≡49≡9(mod10)7^{222} = 7^{4 \cdot 55 + 2} = (7^4)^{55} \cdot 7^2 \equiv 1^{55} \cdot 49 \equiv 49 \equiv 9 \pmod{10}

This technique is fundamental in modular exponentiation algorithms used in cryptography.

Counterexample

Why the coprimality condition is necessary: Consider a=6a = 6, n=9n = 9. We have ϕ(9)=6\phi(9) = 6, but gcd⁡(6,9)=3≠1\gcd(6,9) = 3 \neq 1. Computing: 66=46656=5184⋅96^6 = 46656 = 5184 \cdot 9, so 66≡0(mod9)6^6 \equiv 0 \pmod{9}. Clearly 0≢1(mod9)0 \not\equiv 1 \pmod{9}, so Euler's Theorem fails completely when the coprimality hypothesis is dropped. The issue is that 66 is not a unit in Z/9Z\mathbb{Z}/9\mathbb{Z}—it's a zero divisor, since 6⋅3≡0(mod9)6 \cdot 3 \equiv 0 \pmod{9}. The proof fundamentally relies on being able to cancel common factors, which requires working within the group of units.

🧠 Intuition

Visual mental model: Imagine a clock with nn hours. The totient ϕ(n)\phi(n) counts which hour marks are "reachable by coprime steps"—if you can walk around the clock taking steps of size kk where gcd⁡(k,n)=1\gcd(k,n) = 1, you'll eventually hit exactly ϕ(n)\phi(n) different hours. Euler's Theorem says: if you start at 1 and keep multiplying by any coprime number aa, after exactly ϕ(n)\phi(n) steps you return to 1. The totient measures the "period of multiplication" modulo nn. For prime pp, every nonzero element works (ϕ(p)=p−1\phi(p) = p-1), which is why Fermat's Little Theorem is cleaner. For composite nn, ϕ(n)\phi(n) precisely captures which elements participate in this multiplicative cycling.

Historical Development

Leonhard Euler introduced ϕ(n)\phi(n) in 1763 in his paper Theoremata arithmetica nova methodo demonstrata, though he didn't use the modern notation ϕ\phi (that came later, from Carl Friedrich Gauss's Disquisitiones Arithmeticae in 1801). Euler's motivation was to generalize Fermat's Little Theorem, which Pierre de Fermat had stated (without proof) in 1640 for prime moduli. Fermat claimed that if pp is prime and aa is not divisible by pp, then ap−1≡1(modp)a^{p-1} \equiv 1 \pmod{p}—precisely Euler's Theorem with n=pn = p and ϕ(p)=p−1\phi(p) = p-1. Euler recognized that the quantity p−1p-1 in Fermat's theorem represented the count of nonzero residues modulo pp, and he generalized this counting to arbitrary moduli. His proof used the permutation argument we presented above, showing deep insight into the group structure of units modulo nn, though the language of group theory wouldn't be developed for another century. The explicit product formula for ϕ(n)\phi(n) also appears in Euler's work. Gauss later systematized this theory, proved the multiplicativity rigorously using what we now recognize as the Chinese Remainder Theorem, and established the totient function as a central tool in algebraic number theory. The 20th century saw ϕ(n)\phi(n) take on new importance in cryptography, particularly in the RSA algorithm (1977), where the security relies on the difficulty of computing ϕ(n)\phi(n) without knowing the prime factorization of nn.

Connections to Other Areas

connection

Connection to Cyclotomic Polynomials and Galois Theory: The totient function ϕ(n)\phi(n) equals the degree of the nn-th cyclotomic polynomial Φn(x)\Phi_n(x), which is the minimal polynomial of primitive nn-th roots of unity. Specifically, Φn(x)=∏gcd⁡(k,n)=1,1≤k≤n(x−e2πik/n)\Phi_n(x) = \prod_{\gcd(k,n)=1, 1 \leq k \leq n} (x - e^{2\pi i k/n}) has degree ϕ(n)\phi(n). This connects elementary number theory to Galois theory: the Galois group of Q(ζn)\mathbb{Q}(\zeta_n) over Q\mathbb{Q} (where ζn\zeta_n is a primitive nn-th root of unity) is isomorphic to (Z/nZ)∗(\mathbb{Z}/n\mathbb{Z})^*, the multiplicative group of units modulo nn, which has order ϕ(n)\phi(n). This bridge between counting coprime integers and field extensions is one of the deepest in mathematics.

What You Need First

What This Opens Up

See Also

Fermat's Little Theorem · Chinese Remainder Theorem · Multiplicative Group of Integers Modulo n · Carmichael Function · Cyclotomic Polynomial · RSA Algorithm