Maths WorkshopMaths problems with full solutions
Exercise 645Number theory › Divisibility and gcdM1Added 5 Nov 2026

The sum of φ(d) over the divisors of n

#Euler totient#divisors#counting#fractions

Statement

Let φ\varphi be Euler's totient function (φ(d)\varphi(d) is the number of integers aa with 1≤a≤d1\le a\le d and gcd⁡(a,d)=1\gcd(a,d)=1). Prove that for every positive integer nn,
∑d∣nφ(d)=n.\sum_{d\mid n}\varphi(d)=n.

Hint

Look at the nn fractions 1n,2n,…,nn\frac1n,\frac2n,\dots,\frac nn and write each in lowest terms. What can you say about the denominators?

Show solutionHide solution

Solution

Idea. Count the same set of nn objects in two ways: all together, and grouped according to the denominator in lowest terms.

Grouping. Take k∈{1,…,n}k\in\{1,\dots,n\} and write kn=ad\frac kn=\frac ad in lowest terms, i.e. gcd⁡(a,d)=1\gcd(a,d)=1 and 1≤a≤d1\le a\le d. The denominator dd divides nn (because kn=ad\frac kn=\frac ad gives kd=ankd=an, and gcd⁡(a,d)=1\gcd(a,d)=1 forces d∣nd\mid n).

Counting a group. Fix a divisor dd of nn. A fraction kn\frac kn has lowest-terms denominator dd exactly when it equals ad\frac ad with 1≤a≤d1\le a\le d and gcd⁡(a,d)=1\gcd(a,d)=1. Each such aa gives exactly one k=a⋅ndk=a\cdot\frac nd, and distinct aa give distinct fractions. Hence exactly φ(d)\varphi(d) of the fractions kn\frac kn have denominator dd.

Conclusion. Every one of the nn fractions has exactly one lowest-terms denominator d∣nd\mid n, so
n=∑d∣nφ(d).n=\sum_{d\mid n}\varphi(d).

Check. n=12n=12: φ(1)+φ(2)+φ(3)+φ(4)+φ(6)+φ(12)=1+1+2+2+2+4=12\varphi(1)+\varphi(2)+\varphi(3)+\varphi(4)+\varphi(6)+\varphi(12)=1+1+2+2+2+4=12.

Lesson. Classify the elements of a set by an invariant (here the reduced denominator) and count each class.