%I #24 Jun 12 2024 15:32:25
%S 5,29,599,26699,59669,72869,189389,285839,389999,508619,623669,708989,
%T 862229,908879,945629,945809,953789,1002149,1134389,1138409,1431569,
%U 1461209,1712549,2110289,2127269,2158589,2704769,2727299,2837279,3004049,3068909,3091379,3280229,3336659,3402239,3546269
%N Primes p such that p+2, (p^2-5)/2-p, (p^2-1)/2+p, and (p^2+3)/2+3*p are all prime.
%C Lower twin primes p such that if q = p+2, then (p*q-1)/2, (p*q-1)/2-p-q and (p*q-1)/2+p+q are also prime.
%C All terms but the first == 29 (mod 30).
%H Robert Israel, <a href="/A352951/b352951.txt">Table of n, a(n) for n = 1..2500</a>
%e a(3)=599 is a term because it, 599+2 = 601, (599*601-1)/2 = 179999, 179999-599-601 = 178799, and 179999+599+601 = 181199 are prime.
%p R:= 5: count:= 0:
%p for p from 29 by 30 while count < 60 do
%p if isprime(p) and isprime(p+2) then
%p q:= p+2; r:= (p*q-1)/2;
%p if isprime(r) and isprime(r+p+q) and isprime(r-p-q) then
%p count:= count+1; R:= R,p;
%p fi
%p fi
%p od:
%p R;
%t Select[Prime[Range[250000]], And @@ PrimeQ[{# + 2, (#^2 - 5)/2 - #, (#^2 - 1)/2 + #, (#^2 + 3)/2 + 3*#}] &] (* _Amiram Eldar_, Apr 11 2022 *)
%t Select[Prime[Range[260000]],AllTrue[{#+2,(#^2-5)/2-#,(#^2-1)/2+#,(#^2+3)/2+3#},PrimeQ]&] (* _Harvey P. Dale_, Jun 12 2024 *)
%o (Python)
%o from itertools import islice
%o from sympy import isprime, nextprime
%o def agen(): # generator of terms
%o p, q = 3, 5
%o while True:
%o if q == p+2:
%o t, s = (p*q-1)//2, p+q
%o if isprime(t) and isprime(t+s) and isprime(t-s):
%o yield p
%o p, q = q, nextprime(q)
%o print(list(islice(agen(), 36))) # _Michael S. Branicky_, Apr 10 2022
%Y Cf. A352948.
%Y Subsequence of A001359.
%K nonn
%O 1,1
%A _J. M. Bergot_ and _Robert Israel_, Apr 10 2022