%I #33 May 09 2021 18:32:50
%S 89,389,397,449,661,757,761,929,997,1193,1201,1669,2213,2269,2293,
%T 2593,2609,2617,2741,3037,3041,3209,3217,3413,3433,3449,3697,3877,
%U 4397,4801,5189,5233,5237,5569,5689,5717,6101,6217,6389,6469,6733,6829,6833,6997,7529
%N Smallest of three consecutive prime numbers each of which is the sum of two squares.
%C This sequence is a subsequence of A257117.
%H Harvey P. Dale, <a href="/A257118/b257118.txt">Table of n, a(n) for n = 1..200</a>
%e 389 = 10^2 + 17^2, 397 = 6^2 + 19^2, and 401 = 1^2 + 20^2, so 389 is a term.
%e 397 = 6^2 + 19^2, 401 = 1^2 + 20^2, and 409 = 3^2 + 20^2, so 397 is a term.
%t Prime/@SequencePosition[Table[If[Count[IntegerPartitions[n,{2}],_?(AllTrue[ Sqrt[#],IntegerQ]&)]>0,1,0],{n,Prime[Range[3000]]}],{1,1,1},Overlaps-> All] [[All,1]] (* Requires Mathematica version 10 or later *) (* _Harvey P. Dale_, Jul 08 2018 *)
%o (Python)
%o import sympy
%o def sumpow(sn0,n,p):
%o ....af=0;bf=0;an=1
%o ....sn1=sn0+n
%o ....if n!=0:
%o ........sn1=sympy.nextprime(sn0,n)
%o ....while an**p<sn1:
%o ........bnsq=sn1-(an**p)
%o ........bn=sympy.ntheory.perfect_power(bnsq)
%o ........if bn!=False and list(bn)[1]==p:
%o ............af=an
%o ............bf=list(bn)[0]
%o ............an=sn1+100
%o ........an=an+1
%o ....return(af,bf)
%o s0=1; pw=2
%o while s0>0:
%o ....a0,b0=sumpow(s0,0,pw)
%o ....a1,b1=sumpow(s0,1,pw)
%o ....a2,b2=sumpow(s0,2,pw)
%o ....if a0!=0 and a1!=0 and a2!=0:
%o ........print(s0)
%o ....s0=sympy.nextprime(s0)
%Y Cf. A064716 (Smallest member of three consecutive numbers).
%Y Cf. A257117 (Smallest member of two consecutive prime numbers).
%K nonn,easy
%O 1,1
%A _Abhiram R Devesh_, Apr 25 2015
%E Corrected and extended by and prior b-file replaced by _Harvey P. Dale_, Jul 08 2018
|