OFFSET
1,1
COMMENTS
a(n) is only prime when n is the lesser of a twin prime pair (A001359). All other terms are composite.
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
EXAMPLE
3 is a term because the next prime > 3 is 5, and 5 - 3 = 2, which is prime.
14 is a term because the next prime > 14 is 17, and 17 - 14 = 3, which is prime.
MAPLE
R:= NULL: count:= 0:
q:= 3:
while count < 200 do
p:= nextprime(q);
V:= [seq(p-ithprime(i), i=NumberTheory:-pi(p-q)..1, -1)];
count:= count + nops(V);
R:= R, op(V);
q:= p;
od:
R; # Robert Israel, May 01 2026
MATHEMATICA
Select[Range[130], PrimeQ[NextPrime[#] - #] &] (* Amiram Eldar, Jan 01 2022 *)
PROG
(Python)
from sympy import isprime, nextprime
def ok(n): return n > 0 and isprime(nextprime(n) - n)
print([k for k in range(130) if ok(k)]) # Michael S. Branicky, Jan 01 2022
(PARI) isok(k) = my(p=nextprime(k+1)); isprime(p-k); \\ Michel Marcus, Jan 01 2022
CROSSREFS
KEYWORD
nonn
AUTHOR
Ryan Bresler, Jan 01 2022
STATUS
approved
