Maths WorkshopMaths problems with full solutions
Exercise 1650Number theory › Divisibility and gcdL1Added 3 Nov 2026

Euler's totient function

#Euler totient#coprime#formula

Statement

Show that φ(n)=n∏p∣n(1−1/p)\varphi(n)=n\prod_{p\mid n}(1-1/p) where φ(n)\varphi(n) counts integers 1≤k≤n1\le k\le n with gcd⁡(k,n)=1\gcd(k,n)=1.

Hint

Use inclusion-exclusion on multiples of the prime divisors of nn.

Show solutionHide solution

Solution

Inclusion-exclusion. The number of integers in {1,…,n}\{1,\ldots,n\} coprime to nn equals nn minus those divisible by some prime p∣np\mid n. By inclusion-exclusion:
φ(n)=n−∑p∣nnp+∑p<q∣nnpq−⋯=n∏p∣n(1−1p).\varphi(n)=n-\sum_{p\mid n}\frac np+\sum_{p<q\mid n}\frac{n}{pq}-\cdots=n\prod_{p\mid n}\left(1-\frac1p\right).

Conclusion. The product formula holds.

Example. φ(12)=12(1−1/2)(1−1/3)=12⋅12⋅23=4\varphi(12)=12(1-1/2)(1-1/3)=12\cdot\frac12\cdot\frac23=4 (the integers 1,5,7,111,5,7,11).