%I #17 Sep 06 2022 10:54:16
%S 2,3,5,7,17,29,37,41,43,67,83,103,137,157,179,181,193,227,277,283,347,
%T 359,383,431,457,461,607,661,701,709,757,773,823,827,839,859,937,967,
%U 1013,1051,1061,1109,1129,1187,1201,1213,1249,1283,1307,1327,1373,1423,1439,1471,1481,1487,1543,1567
%N First of three consecutive primes p,q,r such that p*q + q*r + r*p is prime.
%H Robert Israel, <a href="/A356475/b356475.txt">Table of n, a(n) for n = 1..10000</a>
%e a(4) = 7 is a term because 7, 11, 13 are three consecutive primes with 7*11 + 11*13 + 13*7 = 311 which is prime.
%p R:= NULL: count:= 0:
%p P:= Vector(3,ithprime):
%p while count < 100 do
%p x:= P[1]*P[2]+P[2]*P[3]+P[3]*P[1];
%p if isprime(x) then R:= R, P[1]; count:= count+1 fi;
%p P[1..2]:= P[2..3];
%p P[3]:= nextprime(P[3]);
%p od:
%p R;
%t Select[Partition[Prime[Range[250]], 3, 1], PrimeQ[Total[# * RotateLeft[#]]] &][[;; , 1]] (* _Amiram Eldar_, Aug 08 2022 *)
%o (Python)
%o from itertools import islice
%o from sympy import isprime, nextprime
%o def agen():
%o p, q, r = 2, 3, 5
%o while True:
%o if isprime(p*q + q*r + r*p): yield p
%o p, q, r = q, r, nextprime(r)
%o print(list(islice(agen(), 58))) # _Michael S. Branicky_, Aug 08 2022
%o (PARI) list(lim)=my(v=List(),p=2,q=3); forprime(r=5,nextprime(nextprime(lim\1+1)+1), if(isprime(p*q + q*r + r*p), listput(v,p)); p=q; q=r); Vec(v) \\ _Charles R Greathouse IV_, Sep 06 2022
%Y Cf. A189759, A356471, A356477.
%K nonn
%O 1,1
%A _J. M. Bergot_ and _Robert Israel_, Aug 08 2022
|