Find the value of this series:
$$\sum_{i=1}^n \frac{n}{\text{gcd}(i,n)}.$$
Find the value of this series:
$$\sum_{i=1}^n \frac{n}{\text{gcd}(i,n)}.$$
For each divisor $d$ of $n$ there are exactly $\phi\left(\frac nd\right)$ terms in the sum whose value is $\frac nd$, so
$$\sum_{j=1}^n\frac n{(j,n)}=\sum_{d\mid n}\frac nd\phi\left(\frac nd\right)=\sum_{d\mid n}d\phi(d)=\sum_{d\mid n}\phi(d^2)$$