login
a(n) is the least prime p such that p*n+(n-1) and p*n-(n-1) are both prime, or 0 if there is no such p.
2

%I #40 Apr 26 2021 09:03:52

%S 2,2,3,2,3,2,5,3,5,2,3,29,7,0,3,2,0,2,11,3,3,5,0,19,5,3,29,2,0,2,13,0,

%T 3,29,3,2,41,0,5,11,3,11,5,0,5,2,0,3,5,3,19,19,3,11,7,3,11,2,0,2,7,0,

%U 3,5,0,2,5,3,11,5,0,19,13,0,31,7,0,2,19,0,7,11,3,5,19,0,5,2,0,3,7,0,5

%N a(n) is the least prime p such that p*n+(n-1) and p*n-(n-1) are both prime, or 0 if there is no such p.

%C If n == 2 (mod 3) then a(n) <= 3.

%H Robert Israel, <a href="/A342821/b342821.txt">Table of n, a(n) for n = 1..10000</a>

%e a(7) = 5 because 5*7+6 = 41 and 5*7-6 = 29 are prime, and 5 is the least prime that works.

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

%p p:= 1:

%p if n mod 3 = 2 then pmax := 3 else pmax := infinity fi;

%p while p < pmax do

%p p:= nextprime(p);

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

%p od:

%p 0

%p end proc:

%p map(f, [$1..100]);

%Y Cf. A342822.

%K nonn

%O 1,1

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