How to test if a number is a primitive root?
For all $m$, if $m$ is a positive integer then

$g$ is a primitive root mod $m$ $\;$ if and only if

$0\leq g&lt; m$ $\:$ and $\:$ $\operatorname{gcd}(\hspace{.015 in}g,\hspace{-0.01 in}m) = 1$ $\:$ and $\;\;$ for all prime factors $q$ of $\phi$$(m)$, $\: g^{(\phi(m))/q} \not\equiv 1 \pmod m$.