Euler Phi Function of Integer

Theorem
Let $n \in \Z_{>0}$, that is, a (strictly) positive integer.

Let $\phi: \Z_{>0} \to \Z_{>0}$ be the Euler $\phi$-function.

Then for any $n \in \Z_{>0}$, we have:


 * $\phi \left({n}\right) = n \left({1 - \dfrac 1 {p_1} }\right) \left({1 - \dfrac 1 {p_2} }\right) \ldots \left({1 - \dfrac 1 {p_r} }\right)$

where $p_1, p_2, \ldots, p_r$ are the distinct primes dividing $n$.

Or, more compactly:
 * $\displaystyle \phi \left({n}\right) = n \prod_{p \mathop \backslash n} \left({1 - \frac 1 p}\right)$

where $p \mathop \backslash n$ denotes the primes which divide $n$.

Proof
If $n = 1$ the result holds by inspection.

Let $n \ge 2$.

We express $n$ in its prime decomposition:


 * $n = p_1^{k_1} p_2^{k_2} \ldots p_r^{k_r}, p_1 < p_2 < \ldots < p_r$

as it is always possible to do.

By definition, all primes are coprime to each other.

Hence from Euler Phi Function is Multiplicative:


 * $\phi \left({n}\right) = \phi \left({p_1^{k_1}}\right) \phi \left({p_2^{k_2}}\right) \cdots \phi \left({p_r^{k_r}}\right)$

and from Euler Phi Function of Prime Power:
 * $\displaystyle \phi \left({p^k}\right) = p^k \left({1 - \frac 1 p}\right)$

So:
 * $\phi \left({n}\right) = p_1^{k_1} \left({1 - \dfrac 1 {p_1}}\right) p_2^{k_2} \left({1 - \frac 1 {p_2}}\right) \cdots p_r^{k_r} \left({1 - \dfrac 1 {p_r}}\right)$

and the result follows directly from $n = p_1^{k_1} p_2^{k_2} \ldots p_r^{k_r}$.