Mathwords logoMathwords

Euler's Totient Function — Definition, Formula & Examples

Euler's totient function, written ϕ(n)\phi(n), counts how many integers from 11 to nn share no common factor with nn other than 11. For example, ϕ(12)=4\phi(12) = 4 because only 1,5,7,111, 5, 7, 11 are coprime to 1212.

For a positive integer nn, Euler's totient function is defined as ϕ(n)={kZ:1kn,  gcd(k,n)=1}\phi(n) = |\{k \in \mathbb{Z} : 1 \le k \le n,\; \gcd(k, n) = 1\}|. The function is multiplicative: if gcd(a,b)=1\gcd(a,b) = 1, then ϕ(ab)=ϕ(a)ϕ(b)\phi(ab) = \phi(a)\phi(b).

Key Formula

ϕ(n)=npn(11p)\phi(n) = n \prod_{p \mid n} \left(1 - \frac{1}{p}\right)
Where:
  • nn = A positive integer
  • pp = Each distinct prime factor of n

How It Works

To compute ϕ(n)\phi(n), first find the prime factorization of nn. Then apply the product formula, which multiplies nn by a factor of (11/p)(1 - 1/p) for each distinct prime pp dividing nn. For any prime pp, ϕ(p)=p1\phi(p) = p - 1 since every integer less than a prime is coprime to it. The multiplicative property lets you break the computation into smaller pieces when the factorization has multiple distinct primes.

Worked Example

Problem: Compute φ(36).
Factor: Find the prime factorization of 36.
36=22×3236 = 2^2 \times 3^2
Apply the formula: The distinct primes dividing 36 are 2 and 3. Substitute into the product formula.
ϕ(36)=36(112)(113)=361223\phi(36) = 36 \left(1 - \frac{1}{2}\right)\left(1 - \frac{1}{3}\right) = 36 \cdot \frac{1}{2} \cdot \frac{2}{3}
Simplify: Multiply the factors together.
ϕ(36)=3626=12\phi(36) = 36 \cdot \frac{2}{6} = 12
Answer: φ(36) = 12. There are 12 integers between 1 and 36 that are coprime to 36.

Visualization

Why It Matters

Euler's totient function is central to Euler's theorem: aϕ(n)1(modn)a^{\phi(n)} \equiv 1 \pmod{n} when gcd(a,n)=1\gcd(a,n)=1. This theorem underpins the RSA cryptosystem, where ϕ(n)\phi(n) determines the relationship between public and private encryption keys. It also appears throughout number theory in counting problems, group theory (the order of the multiplicative group mod nn), and the Möbius inversion formula.

Common Mistakes

Mistake: Multiplying by (1 − 1/p) for every prime power in the factorization instead of each distinct prime once.
Correction: The product runs over distinct primes only. For n = 36 = 2² × 3², you use (1 − 1/2) and (1 − 1/3), not four separate factors.