A385967 Smallest nonnegative integer whose square is the sum of the squares of A047432(n) distinct primes.
0, 2, 18, 16, 27, 52, 54, 102, 96, 103, 152, 142, 218, 216, 225, 288, 282, 366, 352, 387, 440, 474, 558, 528, 559, 648, 626, 758, 780, 783, 900, 858, 978, 976, 1047, 1112, 1146, 1290, 1248, 1285, 1404, 1394, 1550, 1584, 1587, 1764, 1710, 1866, 1868, 1959, 2048
Offset: 1
Keywords
Examples
a(5) = 27 because prime count A047432(5) = 6 and the smallest sum of squares of 6 distinct primes that is a square is 19^2 + 13^2 + 11^2 + 7^2 + 5^2 + 2^2 = 27^2.
Programs
-
PARI
a(n, c1=0, c2=0, c3=0, ~r, ~pc)={if(c1==0, n--; my(n5=n%5); n=(n-n5)/5*8+n5+if(n5>=2, 2, 0); r=[oo]; pc=vector(max(n-1, 0)); for(i=1, #pc, pc[i]=if(i>1, pc[i-1], 0)+prime(i)^2)); if(c1==n, return(if(issquare(c3), c3, oo))); for(i=n-c1, if(c1, c2-1, oo), my(p2=prime(i)^2); if(c3+p2+if(n-c1-1>0, pc[n-c1-1], 0)>=r[1], break); r[1]=min(r[1], a(n, c1+1, i, c3+p2, ~r, ~pc))); if(c1, r[1], sqrtint(r[1]))}
Comments