Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #16 Sep 05 2022 09:10:37
%S 5,50929,74759,127541,349849,1287731,1294753,3941711,4190023,6130739,
%T 6310061,6593329,6816973,7347709,7573849,8690351,9813409,10985959,
%U 11703187,12130553,12504001,18032059,18468763,20207471,21357191,23635603,24301309,25078181,28509521,28729567,28855459,30200411,31304239
%N Primes p such that, if q is the next prime, p*q+p+q, p*q-p-q, p*q+2*(p+q) and p*q-2*(p+q) are all prime.
%H Robert Israel, <a href="/A356762/b356762.txt">Table of n, a(n) for n = 1..1000</a>
%e a(3) = 74759 is a term because it is prime, the next prime is 74761, and
%e 74759*74761 + 74759 + 74761 = 5589207119
%e 74759*74761 - 74759 - 74761 = 5588908079
%e 74759*74761 + 2*(74759 + 74761) = 5589356639
%e 74759*74761 - 2*(74759 + 74761) = 5588758559
%e are all prime.
%p q:= 2: R:= NULL: count:= 0:
%p while count < 40 do
%p p:= q; q:= nextprime(q); if isprime(p*q+p+q) and isprime(p*q-p-q) and isprime(p*q+2*p+2*q) and
%p isprime(p*q-2*p-2*q) then count:= count+1; R:= R,p; fi
%p od:
%p R;
%t Select[Partition[Prime[Range[2*10^6]], 2, 1], AllTrue[{(p = #[[1]])*(q = #[[2]]) + p + q, p*q - p - q, p*q + 2*(p + q), p*q - 2*(p + q)}, PrimeQ] &][[;; , 1]] (* _Amiram Eldar_, Aug 26 2022 *)
%o (Python)
%o from sympy import isprime, nextprime
%o from itertools import count, islice
%o def agen(): # generator of terms
%o p, q = 2, 3
%o while True:
%o if all(isprime(t) for t in [p*q+p+q, p*q-p-q, p*q+2*(p+q), p*q-2*(p+q)]):
%o yield p
%o p, q = q, nextprime(q)
%o print(list(islice(agen(), 15))) # _Michael S. Branicky_, Aug 26 2022
%Y Cf. A356765.
%K nonn
%O 1,1
%A _J. M. Bergot_ and _Robert Israel_, Aug 26 2022