login
Smallest number with n as least nonnegative primitive root, or 0 if no such number exists.
3

%I #26 Apr 03 2023 10:36:13

%S 1,2,3,4,0,6,41,22,0,0,313,118,4111,457,1031,439,0,262,53173,191,

%T 107227,362,3361,842,533821,0,12391,0,133321,2906,124153,2042,0,3062,

%U 48889,2342,0,7754,55441,19322,1373989,3622,2494381,16022,71761,613034,273001,64682,823766851,0,23126821,115982,129361,29642

%N Smallest number with n as least nonnegative primitive root, or 0 if no such number exists.

%C a(A001597(n)) = 0 for n > 1.

%H G. L. Honaker, Jr. and Chris Caldwell, <a href="https://t5k.org/curios/cpage/25176.html">Prime Curios! 313</a>

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/PrimitiveRoot.html">Primitive Root</a>

%H Robert G. Wilson v, <a href="/A214158/a214158.txt">Table of n, a(n) for n = 0..205</a> (contains -1 where a term has not yet been found)

%e a(7) = 22, since 22 has 7 as smallest positive primitive root and no number < 22 has 7 as smallest positive primitive root.

%t lst2 = {}; r = 47; smallestPrimitiveRoot[n_ /; n <= 1] = 0; smallestPrimitiveRoot[n_] := Block[{pr = PrimitiveRoot[n], g}, If[! NumericQ[pr], g = 0, g = 1; While[g <= pr, If[CoprimeQ[g, n] && MultiplicativeOrder[g, n] == EulerPhi[n], Break[]]; g++]]; g]; lst1 = Union[Flatten@Table[n^i, {i, 2, Log[2, r]}, {n, 2, r^(1/i)}]]; Do[n = 2; If[MemberQ[lst1, l], AppendTo[lst2, 0], While[True, If[smallestPrimitiveRoot[n] == l, AppendTo[lst2, n]; Break[]]; n++]], {l, r}]; Prepend[lst2, 1] (* Most of the code is from _Jean-François Alcover_ *)

%Y Cf. A046145, A046147, A023048.

%K nonn

%O 0,2

%A _Arkadiusz Wesolowski_, Jul 05 2012