login
List the first term of each triple of consecutive primes with the property that their sum is the square of a prime.
2

%I #8 Dec 12 2022 18:03:28

%S 13,37,277,313,613,7591,8209,12157,23053,32233,42953,44887,105649,

%T 225769,245941,258707,287671,331333,342049,346111,347443,393853,

%U 560719,721267,867253,1001089,1064431,1219849,1545127,1556623,1617727,1752607

%N List the first term of each triple of consecutive primes with the property that their sum is the square of a prime.

%H Robert Israel, <a href="/A130621/b130621.txt">Table of n, a(n) for n = 1..3000</a>

%e (37, 41, 43) is a triple of consecutive prime numbers; their sum is 121 which is a prime squared. Hence 37 is in the sequence.

%p f:= proc(n) local p,q,r;

%p q:= prevprime(floor(n/3));

%p p:= prevprime(q);

%p r:= nextprime(q);

%p if p+q+r = n then return p

%p elif p+q+r < n then

%p while p+q+r < n do

%p p:= q; q:= r; r:= nextprime(r);

%p od;

%p if p+q+r = n then return p fi

%p else

%p while p+q+r > n do

%p r:= q; q:= p; p:= prevprime(p);

%p od;

%p if p+q+r = n then return p fi;

%p fi;

%p false

%p end proc:

%p R:= NULL: count:= 0:

%p p:= 3:

%p while count < 100 do

%p p:= nextprime(p);

%p v:= f(p^2);

%p if v::integer then

%p R:= R,v; count:= count+1;

%p fi

%p od:

%p R; # _Robert Israel_, Sep 18 2022

%t a={};For[n=1,n<100000,n++,If[PrimeQ[Sqrt[Prime[n]+Prime[n+1]+Prime[n+2]]], AppendTo[a, Prime[n]]]]; a

%t Select[Partition[Prime[Range[132000]],3,1],PrimeQ[Sqrt[Total[#]]]&][[All,1]] (* _Harvey P. Dale_, Dec 12 2022 *)

%K nonn

%O 1,1

%A _J. M. Bergot_, Jun 18 2007

%E Edited and extended by _Stefan Steinerberger_, Jun 23 2007