OFFSET
1,1
COMMENTS
Also: Numbers which are the sum of two or three distinct nonzero squares. - M. F. Hasler, Feb 03 2013
According to Halter-Koch (below), a number n is a sum of 3 squares, but not a sum of 3 distinct squares (i.e., is in A001974 but not A000408), if and only if it is of the form 4^j*s, where j >= 0 and s in {1, 2, 3, 6, 9, 11, 18, 19, 22, 27, 33, 43, 51, 57, 67, 99, 102, 123, 163, 177, 187, 267, 627, ?}, where ? denotes at most one unknown number that, if it exists, is > 5*10^10. - Jeffrey Shallit, Jan 15 2017
LINKS
T. D. Noe, Table of n, a(n) for n=1..1000
Franz Halter-Koch, Darstellung natürlicher Zahlen als Summe von Quadraten, Acta Arithmetica 42 (1982), pp. 11-20.
EXAMPLE
5 = 0^2 + 1^2 + 2^2.
MATHEMATICA
r[n_] := Reduce[0 <= x < y < z && x^2 + y^2 + z^2 == n, {x, y, z}, Integers]; ok[n_] := r[n] =!= False; Select[ Range[113], ok] (* Jean-François Alcover, Dec 05 2011 *)
PROG
(Python)
from itertools import combinations
def aupto(lim):
s = filter(lambda x: x <= lim, (i*i for i in range(int(lim**.5)+2)))
s3 = set(filter(lambda x: x<=lim, (sum(c) for c in combinations(s, 3))))
return sorted(s3)
print(aupto(113)) # Michael S. Branicky, May 10 2021
CROSSREFS
KEYWORD
nonn,easy,nice
AUTHOR
STATUS
approved