Solution (source code)

= Solution

<Euler's totient function> $\phi(n)$ counts the <integers> $1\le a\le n$ <coprime> to $n$, equivalently the invertible <residue> classes modulo $n$. Among $1,\ldots,p^e$, exactly the $p^{e-1}$ multiples of $p$ are not <coprime> to the <prime power>. Hence
$$
\boxed{\phi(p^e)=p^e-p^{e-1}=p^e(1-1/p).}
$$
Factor $n=\prod_p p^{e_p}$. Its distinct prime-power factors are pairwise <coprime>, so the permitted <multiplicativity> gives
$$
\phi(n)=\prod_{p\mid n}p^{e_p}(1-1/p)
=\boxed{n\prod_{p\mid n}(1-1/p).}
$$
For $n=1$, the <empty product> is one and agrees with $\phi(1)=1$.