Sum of Euler Phi Function over Divisors

Theorem
Let $n \in \Z_{>0}$, i.e. let $n$ be a strictly positive integer.

Then $\displaystyle \sum_{d \mathop \backslash n} \phi \left({d}\right) = n$

where:
 * $\displaystyle \sum_{d \mathop \backslash n}$ denotes the sum over all of the divisors of $n$
 * $\phi \left({d}\right)$ is the Euler $\phi$ function, the number of integers less than $d$ that are prime to $d$.

That is, the total of all the totients of all divisors of a number equals that number.

For example:
 * $\displaystyle \sum_{d \mathop \backslash 12} \phi \left({d}\right) = \phi \left({1}\right) + \phi \left({2}\right) + \phi \left({3}\right) + \phi \left({4}\right) + \phi \left({6}\right) + \phi \left({12}\right) = 12$

Strange but true.

Proof
Let us define $S_d = \left\{{m \in \Z: 1 \le m \le n, \gcd \left\{{m, n}\right\} = d}\right\}$.

That is, $S_d$ is all the numbers less than $n$ whose GCD with $n$ is $d$.

Now from Divide by GCD for Coprime Integers we have:
 * $\gcd \left\{{m, n}\right\} = d \iff \dfrac m d, \dfrac n d \in \Z: \dfrac m d \perp \dfrac n d$

So the number of integers in $S_d$ equals the number of positive integers no bigger than $\dfrac n d$ which are prime to $\dfrac n d$.

That is, $\left|{S_d}\right| = \phi \left({\dfrac n d}\right)$.

Now for each $d_1, d_2, \ldots, d_{\tau \left({n}\right)}$ there exists one $S_{d_j}$, where the index runs to the tau function of $n$.

As each of the integers $1, 2, \ldots, n$ lies in exactly one of the $S_{d_j}$, it follows that:
 * $\displaystyle n = \sum_{d \mathop \backslash n} \phi \left({\dfrac n d}\right)$

But from Sum Over Divisors Equals Sum Over Quotients:
 * $\displaystyle \sum_{d \mathop \backslash n} \phi \left({\dfrac n d}\right) = \sum_{d \mathop \backslash n} \phi \left({d}\right)$

and hence the result.