Totient Function — Definition, Formula & Examples
The totient function, written φ(n), counts how many integers from 1 to n share no common factor with n other than 1. For example, φ(12) = 4 because exactly four numbers in {1, 2, …, 12} are coprime to 12: namely 1, 5, 7, and 11.
For a positive integer , Euler's totient function is defined as . Equivalently, if is the prime factorization of , then . By convention, .
Key Formula
Where:
- = A positive integer whose totient you want to compute
- = Each distinct prime factor of n
How It Works
To compute φ(n), first find the prime factorization of n. Then apply the product formula: multiply n by the factor for each distinct prime dividing n. The totient function is multiplicative, meaning whenever . This property lets you compute φ for large numbers by breaking them into coprime parts. The function appears most famously in Euler's theorem: if , then , which generalizes Fermat's little theorem.
Worked Example
Problem: Compute φ(60).
Step 1: Find the prime factorization of 60.
Step 2: Identify the distinct primes dividing 60: they are 2, 3, and 5.
Step 3: Apply the product formula by multiplying 60 by (1 − 1/p) for each prime.
Step 4: Evaluate each factor and multiply.
Answer: φ(60) = 16. There are 16 integers between 1 and 60 that are coprime to 60.
Another Example
Problem: Use φ to find the remainder when 7^222 is divided by 10.
Step 1: Compute φ(10). Since 10 = 2 × 5, we get:
Step 2: Since gcd(7, 10) = 1, Euler's theorem gives us:
Step 3: Write 222 = 4 × 55 + 2, so 7^222 = (7^4)^55 · 7^2.
Answer: The remainder when 7^222 is divided by 10 is 9.
Visualization
Why It Matters
The totient function is central to the RSA cryptosystem, which secures most internet communications. Computing φ(n) when n is a product of two large primes is easy if you know the primes, but effectively impossible without them — this asymmetry is what makes RSA work. You will encounter φ(n) repeatedly in undergraduate number theory and abstract algebra courses, especially when studying group theory (the group of units modulo n has order φ(n)).
Common Mistakes
Mistake: Including 1 as a prime factor or forgetting that repeated prime factors only appear once in the product formula.
Correction: The product runs over distinct primes only. For n = 12 = 2² × 3, you use (1 − 1/2)(1 − 1/3), not (1 − 1/2)² — the exponents do not affect the number of product terms.
Mistake: Applying Euler's theorem when gcd(a, n) ≠ 1.
Correction: The theorem a^φ(n) ≡ 1 (mod n) requires that a and n be coprime. If they share a common factor, the congruence does not hold.
