OFFSET
1,1
COMMENTS
a(n) can only be composite (excluding a(1) = 5).
EXAMPLE
9 is a term because the next prime > 9 is 11 and the previous prime < 9 is 7, and 11 - 9 = 2 (which is prime) and 9 - 7 = 2 (which is also prime).
MAPLE
q:= n-> andmap(isprime, [nextprime(n)-n, n-prevprime(n)]):
select(q, [$3..400])[]; # Alois P. Heinz, Jan 01 2022
MATHEMATICA
Select[Range[350], And @@ PrimeQ[{# - NextPrime[#, -1], NextPrime[#] - #}] &] (* Amiram Eldar, Jan 01 2022 *)
PROG
(Python)
from sympy import isprime, nextprime, prevprime
def ok(n):
return n > 2 and isprime(nextprime(n) - n) and isprime(n - prevprime(n))
print([k for k in range(341) if ok(k)]) # Michael S. Branicky, Jan 01 2022
(PARI) isok(k) = my(p=nextprime(k+1), q=precprime(k-1)); isprime(p-k) && isprime(k-q); \\ Michel Marcus, Jan 01 2022
CROSSREFS
KEYWORD
nonn
AUTHOR
Ryan Bresler, Jan 01 2022
STATUS
approved