This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A214158 #27 Feb 16 2025 08:33:18 %S A214158 1,2,3,4,0,6,41,22,0,0,313,118,4111,457,1031,439,0,262,53173,191, %T A214158 107227,362,3361,842,533821,0,12391,0,133321,2906,124153,2042,0,3062, %U A214158 48889,2342,0,7754,55441,19322,1373989,3622,2494381,16022,71761,613034,273001,64682,823766851,0,23126821,115982,129361,29642 %N A214158 Smallest number with n as least nonnegative primitive root, or 0 if no such number exists. %C A214158 a(A001597(n)) = 0 for n > 1. %H A214158 G. L. Honaker, Jr. and Chris Caldwell, <a href="https://t5k.org/curios/cpage/25176.html">Prime Curios! 313</a> %H A214158 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/PrimitiveRoot.html">Primitive Root</a> %H A214158 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 A214158 a(7) = 22, since 22 has 7 as smallest positive primitive root and no number < 22 has 7 as smallest positive primitive root. %t A214158 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 A214158 Cf. A046145, A046147, A023048. %K A214158 nonn %O A214158 0,2 %A A214158 _Arkadiusz Wesolowski_, Jul 05 2012