Euler's Phi function

Euler's Phi function, also known as the totient function, is a function that, for a given $$N$$, calculates the number of positive integers smaller than $$N$$ that are relatively prime to $$N$$.

Definition

 * $$\phi(N) = \sum_{ {i=1} \atop {(i,N) = 1} }^{N-1} 1 $$,

where $$(i,N)$$ denotes the greatest common divisor between i and N.

Properties

 * $$\phi(N) = N - 1$$ if $$N$$ is prime.


 * $$\phi(N)$$ is even for all $$N > 2$$.


 * Let $$n = p_1^{\alpha_1} p_2^{\alpha_2}  \cdots  p_x^{\alpha_x}$$, where $$p_i$$ is a prime and $$\alpha_i$$ is a positive integer, such that for any $$0 \leq (i,j) \leq x, i \neq j$$, we have $$p_i \neq p_j$$.  Then
 * $$\phi(N) = N ( 1 - \frac{1}{p_1} )( 1 - \frac{1}{p_2} ) ... ( 1 - \frac{1}{p_x} )$$