Euler's totient function - prove the product formula Let n $\prod_{i=1}^k p_{i}^{e_i}$ with $k\in \mathbb{N}$, $p_i\neq p_j \in \mathbb{P}, \quad \forall i\neq j$ and $e_i \in \mathbb{N}^+$. Then for Euler's totient function follows:
$$\phi(n)=\prod_{i=1}^k (p_i-1)p_{i}^{e_i-1}$$
I have to prove this theorem in the 3 following steps:
1) The formula holds for $n=p^{e_i}$.
This step is done by considering that all numbers $k$ with $gcd(n,k)\neq 1$ have to be multiplicatives of p and there are $p^{e_i-1}$ of them, therefore $\phi(n)=p^{e_i}-p^{e_i-1}$.
2) A residue class is prime modulo $m$, iff it is a unit in the multiplicative  semigroup of $\mathbb{Z}_m$.
3) Use the Chinese remainder theorem and (2) to reduce the problem for arbitrary $n$ to the one of the prime power.
My problem is that I don't know how to prove that for any unit in $\mathbb{Z}_m$ follows that it has to be a prime residue class. The other direction clear to me I can state it if needed.
I would really appreciate some help!
 A: Good strategy.
It's not quite true that the residue class must be prime, but instead that it must be coprime to $m$.
For $x$ to be a unit in the multiplicative group $(\mathbb{Z}/m\mathbb{Z})^\times$ is the same as saying there exists $y$ such that $xy \equiv 1 \bmod m$. In this phrasing, the question is to show that such a $y$ exists exactly when $x$ is coprime to $m$.
We show that if there exists such a $y$, then $x$ must be coprime to $m$ first. The congruence $xy \equiv 1 \bmod m$ implies that there is a $z$ such that $xy + mz = 1$. Any common divisor of $x$ and $m$ must divide $1$, and thus $x$ and $m$ are coprime.
For the converse, we must show that if $\gcd(x,m) = 1$ then $xy \equiv 1 \pmod m$ has a solution (for $y$). This is a classical question (perhaps generally called finding modular inverses), and one typically constructively proves this using the Extended Euclidean Algorithm. See this answer for example.
Together, these imply that the size of the multiplicative group of units for a prime power is $\lvert(\mathbb{Z}/p^n\mathbb{Z})^\times \rvert = p^n - p^{n-1}$, completing your middle step.
