Euler Phi Function of Integer

Theorem
Let $$n \in \Z^*_+$$, that is, a positive integer.

Let $$\phi: \Z^*_+ \to \Z^*_+$$ be the Euler $\phi$-function.

Then for any $$n \in \Z^*_+$$, we have:


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

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

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

Proof
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 we determined it was always possible to do.

As all primes are, by definition, coprime, then from Euler Phi Function is Multiplicative we have:


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

and from Euler Phi Function of a Prime, we have $$\phi \left({p^{k}}\right) = p^{k} \left({1 - \frac 1 {p}}\right)$$

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

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