login
Numbers of the form p^2 + q^2, with p and q primes.
26

%I #47 Oct 06 2022 11:50:50

%S 8,13,18,29,34,50,53,58,74,98,125,130,146,170,173,178,194,218,242,290,

%T 293,298,314,338,365,370,386,410,458,482,530,533,538,554,578,650,698,

%U 722,818,845,850,866,890,962,965,970,986,1010,1058,1082,1130,1202,1250

%N Numbers of the form p^2 + q^2, with p and q primes.

%C A045698(a(n)) > 0. - _Reinhard Zumkeller_, Jul 29 2012

%C All terms greater than 8 are of the form 8k+2 or 8k+5 (A047617). - _Giuseppe Melfi_, Oct 06 2022

%H T. D. Noe, <a href="/A045636/b045636.txt">Table of n, a(n) for n = 1..10000</a>

%H <a href="/index/Su#ssq">Index entries for sequences related to sums of squares</a>

%e 18 belongs to the sequence because it can be written as 3^2 + 3^2.

%t q=13; imax=Prime[q]^2; Select[Union[Flatten[Table[Prime[x]^2+Prime[y]^2, {x,q}, {y,x}]]], #<=imax&] (* _Vladimir Joseph Stephan Orlovsky_, Apr 20 2011 *)

%t With[{nn=60},Take[Union[Total/@(Tuples[Prime[Range[nn]],2]^2)],nn]] (* _Harvey P. Dale_, Jan 04 2014 *)

%o (PARI) list(lim)=my(p1=vector(primepi(sqrt(lim-4)),i,prime(i)^2), t, p2=List()); for(i=1,#p1, for(j=i,#p1, t=p1[i]+p1[j];if(t>lim, break, listput(p2,t)))); vecsort(Vec(p2),,8) \\ _Charles R Greathouse IV_, Jun 21 2012

%o (Haskell)

%o import Data.List (findIndices)

%o a045636 n = a045636_list !! (n-1)

%o a045636_list = findIndices (> 0) a045698_list

%o -- _Reinhard Zumkeller_, Jul 29 2012

%o (Python)

%o from sympy import primerange

%o def aupto(limit):

%o primes = list(primerange(2, int((limit-4)**.5)+2))

%o nums = [p*p + q*q for i, p in enumerate(primes) for q in primes[i:]]

%o return sorted(set(k for k in nums if k <= limit))

%o print(aupto(1251)) # _Michael S. Branicky_, Aug 13 2021

%Y A214723 is a subsequence. Complement: A214879.

%Y Cf. A214511 (least number having n orderless representations as p^2 + q^2).

%Y Cf. A047617.

%K nonn,nice

%O 1,1

%A _Felice Russo_