OFFSET
1,1
COMMENTS
p+q-r is near (and less than) p and odd (for p > 2), so heuristically we would expect it to be prime about 2/log p of the time, yielding around 2x/log^2 x terms up to x. (A more careful analysis of small primes could yield a slightly different leading constant.) - Charles R Greathouse IV, Nov 29 2022
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
EXAMPLE
a(3) = 13 is a prime because 13, 17, 19 are three consecutive primes with 13 + 17 - 19 = 11 prime.
MAPLE
R:= NULL: count:= 0: q:= 2: r:= 3:
while count < 100 do
p:= q; q:= r; r:=nextprime(r);
if isprime(p+q-r) then count:= count+1; R1:= R1, p fi;
od:
R;
MATHEMATICA
Select[Partition[Prime[Range[180]], 3, 1], PrimeQ[#[[1]] + #[[2]] - #[[3]]] &][[;; , 1]] (* Amiram Eldar, Nov 29 2022 *)
PROG
(Python)
from itertools import islice
from sympy import isprime, nextprime
def agen():
p, q, r = 2, 3, 5
while True:
if isprime(p+q-r): yield p
p, q, r = q, r, nextprime(r)
print(list(islice(agen(), 61))) # Michael S. Branicky, Nov 29 2022
(PARI) list(lim)=my(v=List(), p=7, q=11); forprime(r=13, nextprime(nextprime(lim\1+1)+1), if(isprime(p+q-r), listput(v, p)); p=q; q=r); Vec(v) \\ Charles R Greathouse IV, Nov 29 2022
CROSSREFS
KEYWORD
nonn
AUTHOR
J. M. Bergot and Robert Israel, Nov 29 2022
STATUS
approved