login
Least prime p such that 2p+1, 2p+3,..., 2p+2n+1 are not prime.
1

%I #23 Jul 31 2021 09:15:11

%S 7,31,59,59,263,263,263,691,977,1091,1487,1487,2417,2797,4987,4987,

%T 6427,9811,9811,12739,12739,12739,17033,17033,17033,17033,17033,17033,

%U 67261,77969,77969,77969,77969,77969,140717,140717,140717,169019,169019,169019,180331

%N Least prime p such that 2p+1, 2p+3,..., 2p+2n+1 are not prime.

%H Michael S. Branicky, <a href="/A337754/b337754.txt">Table of n, a(n) for n = 0..207</a>

%e a(1) = 31 because 2*31+1=63 and 2*31+3=65 are not prime.

%p nn:=10^8:

%p for n from 1 to 50 do:

%p ii:=0:

%p for k from 2 to nn while(ii=0)do:

%p p:=ithprime(k):jj:=0:

%p for i from 1 by 2 to 2*n-1 do:

%p if isprime(2*p+i)

%p then

%p jj:=1:

%p else

%p fi:

%p od:

%p if jj=0

%p then

%p ii:=1: printf(`%d, `,p):

%p else

%p fi:

%p od:

%p od:

%o (PARI) isok(p, n) = {forstep(k=1, 2*n+1, 2, if (isprime(2*p+k), return (0));); return(1);}

%o a(n) = {my(p=2); while(!isok(p, n), p = nextprime(p+1)); p;} \\ _Michel Marcus_, Sep 21 2020

%o (Python)

%o from sympy import isprime, nextprime

%o def a(n, startp=2):

%o p = startp

%o while any(isprime(2*p+i) for i in range(1, 2*n+2, 2)): p = nextprime(p)

%o return p

%o print([a(n) for n in range(41)]) # _Michael S. Branicky_, Jul 31 2021

%o (Python) # uses above to produce initial segment faster

%o def aupton(nn):

%o an, alst = 2, []

%o for n in range(nn+1): an = a(n, startp=an); alst.append(an)

%o return alst

%o print(aupton(40)) # _Michael S. Branicky_, Jul 31 2021

%Y Cf. A230225.

%K nonn

%O 0,1

%A _Michel Lagneau_, Sep 21 2020