The set V = {1, ... ,n} is the disjoint union of the sets
V | gcd(m,n) = d},where d runs through the set of positive divisors of n (in which case also n/d runs through the set of positive divisors of n.)
For multiples m, n of d, we have gcd(m,n) = d if and only if gcd(m/d,n/d) = 1. The set Vd therefore also equals
V | gcd(m',n/d) = 1}.
Hence
Vd contains
(n/d)
elements and
d |
n, d > 0
(d).
Taking apart the summand
(n) (occurring
for d = n), and bringing the remaining summation to the other
side, we find the required formula.