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 A377940 #6 Nov 11 2024 22:26:36 %S A377940 20,6,32,10,39,28,38,18,18,42,46,42,88,42,46,173,46,78,229,102,102, %T A377940 294,78,150,210,150,210,193,232,193,848,488,330,226,226,328,488,328, %U A377940 294,172,172,294,294,294,462,328,736,328,328,294,1098,328,328,1196,172,172,1322,172,1196,856,1108,889 %N A377940 a(n) is the least number k such that the least j > k for which k is a primitive root is also the least j > n + k for which n + k is a primitive root, or -1 if there is no such k. %C A377940 a(n) is the least k, if it exists, such that 0 < A377938(k) = A377938(k+n). %H A377940 Robert Israel, <a href="/A377940/b377940.txt">Table of n, a(n) for n = 1..500</a> %e A377940 a(3) = 32 because A377938(32) = A377938(35) = 37, i.e. 37 is the least number j > 32 such that 32 is a primitive root mod j and the least number j > 35 such that 35 is a primitive root mod j, and no number less than 32 works. %p A377940 N:= 10^6: %p A377940 P:= select(isprime, {seq(i,i=3..N,2)}):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 A377940 Cands:= sort(convert({4} union Cands, list)): %p A377940 nC:= nops(Cands): %p A377940 Phis:= map(numtheory:-phi, Cands): %p A377940 f:= proc(n) %p A377940 option remember; %p A377940 local k0,k; %p A377940 if issqr(n) then return -1 fi; %p A377940 k0:= ListTools:-BinaryPlace(Cands,n)+1; %p A377940 for k from k0 to nC do %p A377940 if igcd(Cands[k],n) = 1 and numtheory:-order(n,Cands[k]) = Phis[k] then return Cands[k] fi %p A377940 od; %p A377940 FAIL %p A377940 end proc: %p A377940 g:= proc(n) %p A377940 local k; %p A377940 for k from n+1 do %p A377940 if f(k) > 0 and f(k) = f(k+n) then return k %p A377940 elif f(k) = FAIL and f(k+n) = FAIL then return FAIL fi %p A377940 od %p A377940 end proc: %p A377940 map(g, [$1..200]); %Y A377940 Cf. A377938. %K A377940 nonn %O A377940 1,1 %A A377940 _Robert Israel_, Nov 11 2024