Euler's Totient Function and Euler's Theorem

⚡ Key Takeaways

Euler's totient function φ(n)\varphi(n) counts the positive integers up to nn that are coprime to nn. Euler's theorem states that if gcd⁡(a,n)=1\gcd(a,n)=1, then aφ(n)≡1(modn)a^{\varphi(n)}\equiv 1 \pmod n. These tools underpin modular arithmetic, cyclic group structure, and the RSA cryptosystem. Introduced by Leonhard Euler in 1763.

💡 The Core Insight

The integers coprime to nn form a group under multiplication modulo nn — the unit group (Z/nZ)×(\mathbb{Z}/n\mathbb{Z})^\times — and that group has exactly φ(n)\varphi(n) elements. By Lagrange's theorem, every element raised to the size of the group returns to the identity. That single structural fact, applied to a finite abelian group of units, is Euler's theorem.

Formal Statement

DefinitionEuler's Totient Function

For a positive integer nn, the totient φ(n)\varphi(n) is the number of integers kk in the range 1≤k≤n1\le k\le n satisfying gcd⁡(k,n)=1\gcd(k,n)=1:

1
φ(n)=#{ k∈Z:1≤k≤n, gcd⁡(k,n)=1 }\quad \varphi(n) = \#\{\,k\in\mathbb{Z} : 1\le k\le n,\ \gcd(k,n)=1\,\}

Derivation hint: Directly count the residues modulo nn that have a multiplicative inverse; by convention φ(1)=1\varphi(1)=1 since gcd⁡(1,1)=1\gcd(1,1)=1. Symbols: nn is the modulus; kk ranges over representatives of residue classes; gcd⁡\gcd is the greatest common divisor. Equivalently, φ(n)=∣(Z/nZ)×∣\varphi(n)=|(\mathbb{Z}/n\mathbb{Z})^\times|, the order of the group of units.

DefinitionProduct Formula

If n=p1a1p2a2⋯prarn = p_1^{a_1} p_2^{a_2}\cdots p_r^{a_r} is the prime factorization of n>1n>1, then

2
φ(n)=n∏p∣n(1−1p)=∏i=1rpiai−1(pi−1)\quad \varphi(n) = n\prod_{p\mid n}\left(1-\frac{1}{p}\right) = \prod_{i=1}^{r} p_i^{a_i-1}(p_i-1)

Derivation hint: Compute φ(pa)=pa−pa−1\varphi(p^a)=p^a-p^{a-1} for prime powers, then multiply across distinct primes using multiplicativity (Theorem below). Symbols: the product ∏p∣n\prod_{p\mid n} runs over distinct prime divisors pp of nn; each factor (1−1/p)(1-1/p) removes the fraction of integers divisible by pp.

TheoremMultiplicativity

If gcd⁡(m,n)=1\gcd(m,n)=1, then

3
φ(mn)=φ(m) φ(n).\quad \varphi(mn) = \varphi(m)\,\varphi(n).

Derivation hint: The Chinese Remainder Theorem gives a ring isomorphism Z/mnZ≅Z/mZ×Z/nZ\mathbb{Z}/mn\mathbb{Z}\cong \mathbb{Z}/m\mathbb{Z}\times\mathbb{Z}/n\mathbb{Z}, which restricts to a bijection of unit groups, so unit counts multiply. Note: φ\varphi is multiplicative but not completely multiplicative; e.g. φ(4)=2≠φ(2)2=1\varphi(4)=2\ne\varphi(2)^2=1.

TheoremEuler's Theorem

If aa and nn are integers with n≥1n\ge 1 and gcd⁡(a,n)=1\gcd(a,n)=1, then

4
aφ(n)≡1(modn).\quad a^{\varphi(n)} \equiv 1 \pmod n.

Derivation hint: aa represents a unit in (Z/nZ)×(\mathbb{Z}/n\mathbb{Z})^\times, a finite group of order φ(n)\varphi(n); apply Lagrange's theorem, whose corollary forces g∣G∣=eg^{|G|}=e for all g∈Gg\in G. When n=pn=p is prime, φ(p)=p−1\varphi(p)=p-1 and [4] becomes Fermat's little theorem: ap−1≡1(modp)a^{p-1}\equiv 1\pmod p for p∤ap\nmid a.

TheoremDivisor-Sum Identity (Gauss)

For every positive integer nn,

5
∑d∣nφ(d)=n.\quad \sum_{d\mid n}\varphi(d) = n.

Derivation hint: Partition the nn fractions 1/n,2/n,…,n/n1/n,2/n,\dots,n/n by their reduced denominator d∣nd\mid n; exactly φ(d)\varphi(d) of them reduce to a fraction with denominator dd.

Why It Holds

ProofEuler's Theorem via Group Theory

Step 1. Let G=(Z/nZ)×G = (\mathbb{Z}/n\mathbb{Z})^\times, the set of residue classes coprime to nn. Closure holds: if gcd⁡(a,n)=gcd⁡(b,n)=1\gcd(a,n)=\gcd(b,n)=1 then gcd⁡(ab,n)=1\gcd(ab,n)=1. Associativity and the identity 1ˉ\bar 1 are inherited from Z/nZ\mathbb{Z}/n\mathbb{Z}. Inverses exist because gcd⁡(a,n)=1\gcd(a,n)=1 means ax≡1ax\equiv 1 is solvable by Bézout. Hence GG is a finite abelian group with ∣G∣=φ(n)|G|=\varphi(n).

Step 2. Fix a∈Ga\in G and consider its cyclic subgroup ⟨a⟩={1ˉ,a,a2,… }\langle a\rangle = \{\bar1, a, a^2, \dots\}. Let d=ord⁡(a)d=\operatorname{ord}(a), the smallest positive integer with ad≡1a^d\equiv 1. Then ∣⟨a⟩∣=d|\langle a\rangle| = d.

Step 3. By Lagrange's theorem, the order of any subgroup divides the order of the group: d∣φ(n)d \mid \varphi(n). Write φ(n)=d⋅q\varphi(n)=d\cdot q.

Step 4. Therefore

aφ(n)=adq=(ad)q≡1ˉ q=1ˉ(modn).a^{\varphi(n)} = a^{dq} = (a^d)^q \equiv \bar1^{\,q} = \bar1 \pmod n.

This is exactly [4]. ■\blacksquare

∎
ProofEuler's Theorem via Permuted Residues (elementary)

Step 1. Let r1,r2,…,rφ(n)r_1,r_2,\dots,r_{\varphi(n)} be a reduced residue system — one representative from each class coprime to nn.

Step 2. Since gcd⁡(a,n)=1\gcd(a,n)=1, the map ri↦ari  nr_i\mapsto a r_i \bmod n permutes this set: each ariar_i is still coprime to nn, and ari≡arjar_i\equiv ar_j forces ri≡rjr_i\equiv r_j (cancel the unit aa). So {ar1,…,arφ(n)}\{ar_1,\dots,ar_{\varphi(n)}\} is a permutation of {r1,…,rφ(n)}\{r_1,\dots,r_{\varphi(n)}\} modulo nn.

Step 3. Multiply all elements of each set:

∏i=1φ(n)(ari)≡∏i=1φ(n)ri(modn)  ⟹  aφ(n)∏iri≡∏iri(modn).\prod_{i=1}^{\varphi(n)} (a r_i) \equiv \prod_{i=1}^{\varphi(n)} r_i \pmod n \;\Longrightarrow\; a^{\varphi(n)}\prod_i r_i \equiv \prod_i r_i \pmod n.

Step 4. Each rir_i is invertible, so ∏iri\prod_i r_i is a unit and may be cancelled, yielding aφ(n)≡1(modn)a^{\varphi(n)}\equiv 1\pmod n. ■\blacksquare

∎
mathematician · Leonhard Euler | 1707–1783

The Swiss polymath Euler introduced the totient (he wrote it as πD\pi D for a number DD) while extending Fermat's little theorem to composite moduli, publishing the result in Theoremata arithmetica nova methodo demonstrata (1763). Across an unmatched output of nearly 900 works, Euler founded analytic number theory, introduced the zeta function and its product over primes, and codified the notation (ee, ii, Σ\Sigma, f(x)f(x)) that students still use. The symbol φ\varphi for the totient was later popularized by Gauss in Disquisitiones Arithmeticae (1801), where the function received its systematic treatment.

Building Intuition

🧠 Intuition

Think of φ(n)\varphi(n) as a sieve count. Start with all nn integers from 11 to nn; the factor (1−1/p)(1-1/p) in [2] discards exactly the fraction 1/p1/p that are divisible by pp. Because divisibility by distinct primes is "independent" (a probabilistic shadow of the Chinese Remainder Theorem), you simply multiply the surviving fractions. For Euler's theorem, picture the units modulo nn as beads on a finite necklace. Multiplying everything by a unit aa just rotates the necklace — it relabels the beads without losing any. Since the necklace has φ(n)\varphi(n) beads, repeating the rotation φ(n)\varphi(n) times (i.e. raising to the φ(n)\varphi(n) power) lands you exactly back where you started.

Figure
Sieving the totient: integers 1–12 with those coprime to 12 highlighted
n = 12 = 2²·3, φ(12) = 12(1−½)(1−⅓) = 4 1 2 3 4 5 6 7 8 9 10 11 12 coprime to 12: {1, 5, 7, 11} → 4 elements grey = shares a factor 2 or 3 with 12 (sieved out)

Worked Examples

ExampleComputing φ(360)

Given: n=360n = 360.

Step 1 — Factor: 360=23⋅32⋅5360 = 2^3\cdot 3^2\cdot 5.

Step 2 — Apply product form [2]:

φ(360)=23−1(2−1)⋅32−1(3−1)⋅51−1(5−1)=4⋅1  ⋅  3⋅2  ⋅  1⋅4.\varphi(360)=2^{3-1}(2-1)\cdot 3^{2-1}(3-1)\cdot 5^{1-1}(5-1) = 4\cdot1\;\cdot\;3\cdot2\;\cdot\;1\cdot4.

Step 3 — Multiply: 4⋅6⋅4=964\cdot 6\cdot 4 = 96.

Check via fractions: 360⋅(1−12)(1−13)(1−15)=360⋅12⋅23⋅45=96.360\cdot(1-\tfrac12)(1-\tfrac13)(1-\tfrac15)=360\cdot\tfrac12\cdot\tfrac23\cdot\tfrac45=96. ✓

φ(360)=96\boxed{\varphi(360) = 96}
ExampleUsing Euler's Theorem to find the last two digits of 78037^{803}

Given: compute 7803  1007^{803}\bmod 100 (the last two digits in base 10).

Step 1 — Totient of modulus: 100=22⋅52100=2^2\cdot5^2, so φ(100)=100(1−12)(1−15)=100⋅12⋅45=40\varphi(100)=100(1-\tfrac12)(1-\tfrac15)=100\cdot\tfrac12\cdot\tfrac45=40.

Step 2 — Check coprimality: gcd⁡(7,100)=1\gcd(7,100)=1, so Euler's theorem [4] gives 740≡1(mod100)7^{40}\equiv1\pmod{100}.

Step 3 — Reduce the exponent mod 40: 803=40⋅20+3803 = 40\cdot20 + 3, so 7803=(740)20⋅73≡73(mod100)7^{803}=(7^{40})^{20}\cdot7^3\equiv 7^3\pmod{100}.

Step 4 — Evaluate: 73=343≡43(mod100)7^3 = 343 \equiv 43 \pmod{100}.

7803≡43(mod100)(last two digits=43)\boxed{7^{803}\equiv 43 \pmod{100}\quad(\text{last two digits} = 43)}

Common Misconceptions

⚠️ Common mistake

Euler's theorem requires coprimality. The congruence aφ(n)≡1(modn)a^{\varphi(n)}\equiv 1\pmod n holds only when gcd⁡(a,n)=1\gcd(a,n)=1. If aa shares a factor with nn, aa is not a unit and the conclusion generally fails — for such cases use the Carmichael function λ(n)\lambda(n) or handle prime-power factors separately. Also: reducing exponents works modulo φ(n)\varphi(n), not modulo nn. To simplify ae  na^e\bmod n, reduce ee modulo φ(n)\varphi(n) (when gcd⁡(a,n)=1\gcd(a,n)=1), never modulo nn itself.

Counterexample

Take n=6n=6 and a=4a=4. Here gcd⁡(4,6)=2≠1\gcd(4,6)=2\ne1, and φ(6)=2\varphi(6)=2. Euler's theorem would predict 42≡1(mod6)4^{2}\equiv1\pmod6, but 42=16≡4(mod6)4^2=16\equiv 4\pmod 6, not 11. The hypothesis fails, so the conclusion fails. Indeed 4k≡4(mod6)4^k\equiv4\pmod6 for all k≥1k\ge1 — the powers of 44 never reach 11.

Counterexample

φ\varphi is not completely multiplicative. One might guess φ(mn)=φ(m)φ(n)\varphi(mn)=\varphi(m)\varphi(n) always, but [3] requires gcd⁡(m,n)=1\gcd(m,n)=1. With m=n=6m=n=6 (not coprime): φ(36)=36(1−12)(1−13)=12\varphi(36)=36(1-\tfrac12)(1-\tfrac13)=12, whereas φ(6)φ(6)=2⋅2=4≠12\varphi(6)\varphi(6)=2\cdot2=4\ne12.

Connections

connection

Euler's theorem is the composite-modulus parent of Fermat's Little Theorem (the prime case) and a direct corollary of Lagrange's Theorem applied to the Group of Units Modulo n. The product formula [2] flows from the Chinese Remainder Theorem and exhibits φ\varphi as a Multiplicative Function in Analytic Number Theory, where it appears in the Dirichlet Series identity ∑φ(n)n−s=ζ(s−1)/ζ(s)\sum \varphi(n)n^{-s} = \zeta(s-1)/\zeta(s). The divisor-sum identity [5] is a clean application of Möbius Inversion, giving φ(n)=∑d∣nμ(d) n/d\varphi(n)=\sum_{d\mid n}\mu(d)\,n/d. Structurally, φ(n)\varphi(n) measures the order of the abelian group studied in Cyclic Groups and Primitive Roots.

Real-World Applications

🔬 Where this appears

Historical Development

⏳ History
- 1640 — Pierre de Fermat states (without proof) his little theorem ap≡a(modp)a^{p}\equiv a\pmod p in correspondence with Frénicle de Bessy.
- 1736 — Euler publishes the first proof of Fermat's little theorem.
- 1763 — Euler generalizes it to composite moduli, introducing the totient in Theoremata arithmetica nova methodo demonstrata, proving aφ(n)≡1(modn)a^{\varphi(n)}\equiv1\pmod n.
- 1801 — Gauss systematizes the function in Disquisitiones Arithmeticae, popularizing the notation and proving the divisor-sum identity [5].
- 1832 — Gauss and contemporaries clarify the structure of (Z/nZ)×(\mathbb{Z}/n\mathbb{Z})^\times and existence of primitive roots.
- 1879 — J. J. Sylvester coins the term totient.
- 1900s — Robert Carmichael introduces the function λ(n)\lambda(n), the exact (least universal) exponent, refining Euler's bound.
- 1933 — Edmund Landau and others establish asymptotics: ∑n≤xφ(n)∼3π2x2\sum_{n\le x}\varphi(n)\sim \tfrac{3}{\pi^2}x^2.
- 1977 — Rivest, Shamir, and Adleman publish RSA, turning φ\varphi and Euler's theorem into the backbone of public-key cryptography.

Subtleties & Limits

open-problem

Lehmer's totient problem (1932) asks whether there exists a composite nn with φ(n)∣(n−1)\varphi(n)\mid (n-1). Every prime pp satisfies φ(p)=p−1∣p−1\varphi(p)=p-1\mid p-1; D. H. Lehmer conjectured no composite does, but the question remains open. Any counterexample must be odd, squarefree, and have at least 15 prime factors exceeding 102010^{20}. Relatedly, Carmichael's totient conjecture posits that no value of φ\varphi is attained exactly once — for every nn there is some m≠nm\ne n with φ(m)=φ(n)\varphi(m)=\varphi(n); verified to enormous bounds but unproven. These show that despite its elementary definition, φ\varphi still hides deep mysteries.

See Also

Fermat's Little Theorem · Lagrange's Theorem · Group of Units Modulo n · Chinese Remainder Theorem · Carmichael Function · Primitive Roots · Möbius Function and Inversion · RSA Cryptosystem · Multiplicative Function