OFFSET
2,2
LINKS
T. D. Noe, Table of n, a(n) for n = 2..3119 (first 99 nonempty rows of triangle, flattened)
Eric Weisstein's World of Mathematics, Primitive Root.
EXAMPLE
n followed by primitive roots, if any:
1 -
2 1
3 2
4 3
5 2 3
6 5
7 3 5
8 -
9 2 5
10 3 7
11 2 6 7 8
12 -
13 2 6 7 11
...
MAPLE
f:= proc(n) local p, k, m, R;
p:= numtheory:-primroot(n);
if p = FAIL then return NULL fi;
m:= numtheory:-phi(n);
k:= select(i -> igcd(i, m) = 1, [$1..m-1]);
op(sort(map(t -> p&^t mod n, k)))
end proc:
f(2):= 1:
map(f, [$2..50]); # Robert Israel, Apr 28 2017
MATHEMATICA
a[n_] := Select[Range[n-1], GCD[#, n] == 1 && MultiplicativeOrder[#, n] == EulerPhi[n]& ]; Table[a[n], {n, 1, 30}] // Flatten (* Jean-François Alcover, Oct 23 2012 *)
PrimitiveRootList[Range[Prime[10]]]//Flatten (* Requires Mathematica version 10 or later *) (* Harvey P. Dale, Sep 10 2016 *)
PROG
(PARI) a_row(r) = my(v=[], phi=eulerphi(r)); for(i=1, r-1, if(1 == gcd(r, i) && phi == znorder(Mod(i, r)), v=concat(v, i))); v \\ Ruud H.G. van Tol, Oct 23 2023
CROSSREFS
KEYWORD
nonn,tabf
AUTHOR
EXTENSIONS
Edited by Robert Israel, Apr 28 2017
STATUS
approved