For every prime number \(m\) there exists a natural number \(n\) that
generates the field \(F_m\), i.e. \(n, n^2, ..., n^{m-1} mod (m)\) are
all different.
The computation here is all brute force. As most primitive roots are
relatively small, it is still reasonable fast.
One trick is to factorize \(m-1\) and test only for those prime factors.
In R this is not more efficient as factorization also takes some time.