OFFSET
1,2
COMMENTS
s3(k) is defined exactly when k is a sum of three squares; i.e., k is not of the form 4^a*(8b+7) (Legendre). It is the spread of the "most balanced" three-square representation. s3(k) = 0 iff k = 3*m^2, then x = y = z = m. This sequence lists the k where s3 reaches a new maximum.
The first six primitive record locations (terms not equal to 4 times an earlier record) are 1, 10, 37, 58, 130, 445, with respective spreads 1, 3, 6, 7, 9, 17. Since a sum of three squares is divisible by 4 only when all three squares are even, every representation of 4*k halves to one of k and conversely, giving s3(4*k) = 2*s3(k).
LINKS
Nenad Micic, Table of n, a(n) for n = 1..65
FORMULA
Conjecture: a(n) = 4*a(n-5) for n >= 13, with initial terms a(1)..a(12) = 1, 4, 10, 16, 37, 58, 64, 130, 148, 232, 256, 445.
EXAMPLE
k = 1: 1 = 1^2+0^2+0^2, spread 1-0 = 1 (first record).
k = 10: 10 = 3^2+1^2+0^2, spread 3-0 = 3 (new record).
k = 37: 37 = 6^2+1^2+0^2, spread 6-0 = 6 (new record).
k = 445: 445 = 20^2+6^2+3^2, spread 20-3 = 17 (new record; first record whose tightest triple has all three parts positive).
PROG
(PARI)
issum3(n) = {if(n<1, return(n==0)); while(n%4==0, n\=4); n%8 != 7};
s3(n) = {my(b=oo, zr=sqrtint(n\3)); forstep(z=zr, 0, -1, my(m=n-z^2, xl=sqrtint(m\2)); while(2*xl^2<m, xl++); if(xl-z>=b, break); for(x=xl, sqrtint(m), if(x-z>=b, break); my(y2=m-x^2); if(issquare(y2) && sqrtint(y2)>=z, b=x-z; break))); b};
lista(N) = {my(rec=-1); for(k=1, N, if(issum3(k), my(s=s3(k)); if(s>rec, rec=s; print1(k, ", "))))};
\\ lista(N) prints the record locations up to N.
CROSSREFS
KEYWORD
nonn
AUTHOR
Nenad Micic, Jun 10 2026
STATUS
approved
