Lemma.$$\sum_{d \mid n} \phi(d)=n$$
ProofConsidering the set of fractions $\left\{\frac{1}{n}, \frac{2}{n}, \ldots, \frac{n-1}{n}, \frac{n}{n}\right\}=\left\{\frac{a_{1}}{b_{1}}, \frac{a_{2}}{b_{2}}, \ldots, \frac{a_{n-1}}{b_{n-1}}, \frac{a_{n}}{b_{n}}\right\}$ where $\left(a_i, b_i\right)=1$.
The set $\mathcal{D}$ of all denominators $\left\{b_i\right\}$ is precisely the set of all divisors of $n$.
Given a divisor $d$ of $n$, $d$ appears in the set $\mathcal{D}$ exactly $\varphi(d)$ times:
$$
\frac{a_i}{b_i}=\frac{a_i}{d}=\frac{a_i \frac{n}{d}}{n},
$$
where $\left(a_i, d\right)=1$ and $1 \leq a_i \leq d$.
Counting the elements in $\mathcal{D}$ in two different ways implies $n=\sum_{d \mid n} \varphi(d)$. Möbius Inversion formula immediately gives
$$\phi(n)=\sum_{d \mid n} \mu(d) \frac{n}{d}$$
Debanjana Kundu |