login
a(n) is the least k such that A342821(k) = prime(n).
2

%I #30 Apr 26 2021 09:04:11

%S 1,3,7,13,19,31,126,24,241,12,75,193,37,180,318,496,154,142,328,117,

%T 838,415,423,367,783,124,1018,1621,334,118,973,619,1453,349,337,1089,

%U 1825,1593,888,613,649,324,1509,2413,733,727,342,573,4648,387,1663,2827,2260,129,3363,3723,2239,1159,3868

%N a(n) is the least k such that A342821(k) = prime(n).

%C If p = prime(n), a(n) is the least k such that p*k+k-1 and p*k-k+1 are prime but for every prime q < p, q*k+k-1 and q*k-k+1 are not both prime.

%H Robert Israel, <a href="/A342822/b342822.txt">Table of n, a(n) for n = 1..894</a>

%e a(5) = 19 because A342821(19) = prime(5) = 11 and this is the first appearance of 11 in A342821.

%p N:= 100: # for a(1)..a(N)

%p V:= Vector(N):

%p g:= proc(n) local ip, p; pmax;

%p for ip from 1 to `if`(n mod 3 = 2, 2,infinity) do

%p p:= ithprime(ip);

%p if isprime(n*p+n-1) and isprime(n*p-n+1) then return ip fi;

%p od:

%p 0

%p end proc:

%p count:= 0:

%p for n from 1 while count < N do

%p v:= g(n);

%p if v >= 1 and v <= N and V[v] = 0 then

%p count:= count+1; V[v]:= n;

%p fi

%p od:

%p convert(V,list);

%Y Cf. A342821.

%K nonn

%O 1,2

%A _J. M. Bergot_ and _Robert Israel_, Apr 25 2021