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 A377938 #12 Nov 11 2024 22:26:08 %S A377938 2,3,4,-1,6,11,10,11,-1,17,13,17,19,17,19,-1,22,29,22,23,23,25,25,31, %T A377938 -1,29,29,41,34,41,34,37,38,41,37,-1,46,47,47,47,47,59,46,47,47,67,49, %U A377938 53,-1,53,53,59,62,59,58,59,67,73,61,73,67,71,67,-1,71,79,71,71,71,79,82,83,83,79,79 %N A377938 a(n) is the least k > n such that n is a primitive root modulo k, or -1 if there is no such k. %C A377938 a(n) <= A023049(n). %C A377938 a(n) = 0 iff n is a square > 1. %H A377938 Robert Israel, <a href="/A377938/b377938.txt">Table of n, a(n) for n = 1..10000</a> %e A377938 a(6) = 11 because 6 is a primitive root mod 11 and no number from 7 to 10 has 6 as a primitive root. %p A377938 N:= 1000: # to allow values <= N %p A377938 P:= select(isprime, {seq(i,i=3..N,2)}): %p A377938 Cands:= map(proc(t) local i; (seq(t^i,i=1..ilog[t](N)), seq(2*t^i,i=1..ilog[t](N/2))) end proc,P): %p A377938 Cands:= sort(convert({4} union Cands, list)): %p A377938 Phis:= map(numtheory:-phi, Cands): %p A377938 f:= proc(n) %p A377938 local k0,k; %p A377938 if issqr(n) then return -1 fi; %p A377938 k0:= ListTools:-BinaryPlace(Cands,n)+1; %p A377938 for k from k0 do %p A377938 if igcd(Cands[k],n) = 1 and numtheory:-order(n,Cands[k]) = Phis[k] then return Cands[k] fi %p A377938 od %p A377938 end proc: %p A377938 f(1):= 2: %p A377938 map(f, [$1..200]); %Y A377938 Cf. A023049, A377939. A377940. %K A377938 sign %O A377938 1,1 %A A377938 _Robert Israel_, Nov 11 2024