login
a(n) is the smallest generator for the group of numbers relatively prime to n under multiplication mod n; a(n) = -1 if n is not a power of a prime or twice a power of a prime.
1

%I #28 Jan 21 2015 03:19:10

%S 1,2,3,2,5,3,-1,2,3,2,-1,2,3,-1,-1,3,5,2,-1,-1,7,5,-1,2,7,2,-1,2,-1,3,

%T -1,-1,3,-1,-1,2,3,-1,-1,6,-1,3,-1,-1,5,5,-1,3,3,-1,-1,2,5,-1,-1,-1,3,

%U 2,-1,2,3,-1,-1,-1,-1,2,-1,-1,-1,7,-1,5,5,-1,-1,-1,-1,3,-1,2,7,2,-1,-1,3,-1,-1,3,-1,-1,-1,-1,5,-1,-1,5,3,-1,-1

%N a(n) is the smallest generator for the group of numbers relatively prime to n under multiplication mod n; a(n) = -1 if n is not a power of a prime or twice a power of a prime.

%C Same as A046145, except for taking -1 instead of 0. - _Joerg Arndt_, Jan 16 2015

%p subs(FAIL=-1, [seq(numtheory:-primroot(n), n=2..1000)]); # _Robert Israel_, Jan 11 2015

%t lst = {}; f[n_] := PrimitiveRoot[n]; Do[If[IntegerQ@f[n], g = f[n], g = -1]; AppendTo[lst, g], {n, 2, 73}]; Prepend[lst, -1]

%Y Cf. A046145.

%K easy,sign

%O 2,2

%A _Vladimir Joseph Stephan Orlovsky_, Mar 23 2010

%E Name changed by _Arkadiusz Wesolowski_, Jul 19 2012

%E Offset changed and ambiguous term a(0) removed by _Arkadiusz Wesolowski_, Jul 20 2012

%E a(1) removed by _Joerg Arndt_, Jan 11 2015