TITLE: Is there a direct, elementary proof of $n = \sum_{k|n} \phi(k)$?
QUESTION [30 upvotes]: If $k$ is a positive natural number then $\phi(k)$ denotes the number of natural numbers less than $k$ which are prime to $k$. I have seen proofs that $n = \sum_{k|n} \phi(k)$ which basically partitions $\mathbb{Z}/n\mathbb{Z}$ into subsets of elements of order $k$ (of which there are $\phi(k)$-many) as $k$ ranges over divisors of $n$.
But everything we know about $\mathbb{Z}/n\mathbb{Z}$ comes from elementary number theory (division with remainder, bezout relations, divisibility), so the above relation should be provable without invoking the structure of the group $\mathbb{Z}/n\mathbb{Z}$. Does anyone have a nice, clear, proof which avoids $\mathbb{Z}/n\mathbb{Z}$?

REPLY [3 votes]: This proof uses Möbius inversion, and is pretty quick! Recall the function
 $$
 \mu(n) =
 \begin{cases} 
 (-1)^{\nu(n)} \qquad \text{if $n$ is square free} \\
 0 \,\,\qquad\qquad\text{otherwise},
\end{cases}
 $$
where $\nu(n)$ is the number of distinct prime divisors of $n$. The Möbius inversion formula says that
  $$
 f(n)=\sum_{d\mid n} g(d) 
 $$ 
 if and only if
 $$
 g(n)=\sum_{d\mid n}\mu(d)f(n/d).
 $$
Putting $f(n)=n$ and $g(n)=\varphi(n)$, by Möbius it suffices to show 
$$
\varphi(n)=\sum_{d\mid n}\mu(d)\frac{n}{d},
$$
and this is true since 
\begin{align*}
\varphi(n)&=n \prod_{p\mid n}\bigg(1-\frac{1}{p}\bigg)\\
&=n \sum_{d\mid n}\frac{\mu(d)}{d}\\
&=\sum_{d\mid n}\mu(d)\frac{n}{d}.
\end{align*}
(Note that $\prod_{p\mid n}\big(1-\frac{1}{p}\big)=\sum_{d\mid n}\frac{\mu(d)}{d}$ since terms in the sum are zero except at divisors of $d$ that consist of distinct primes, and multiplying out the product on the right gives precisely this sum.)