Primitive-root modulus classification (source code)

= Primitive-root modulus classification

An integer $n$ has a primitive root exactly when
$$
n\in\{1,2,4,p^a,2p^a\},
$$
where $p$ is an odd prime and $a\geq1$. When primitive roots exist, their number is $\varphi(\varphi(n))$.