OFFSET
1,1
LINKS
FORMULA
EXAMPLE
30 = 1^2+2^2+3^2+4^2.
MATHEMATICA
data = Flatten[ DeleteCases[ FindInstance[ w^2 + x^2 + y^2 + z^2 == # && 0 < w < x < y < z < #, {w, x, y, z}, Integers] & /@ Range[137], {}], 1]; w^2 + x^2 + y^2 + z^2 /. data (* Ant King, Oct 17 2010 *)
Select[Union[Total[#^2]&/@Subsets[Range[10], {4}]], #<=137&] (* Harvey P. Dale, Jul 03 2011 *)
PROG
(Haskell)
a004433 n = a004433_list !! (n-1)
a004433_list = filter (p 4 $ tail a000290_list) [1..] where
p k (q:qs) m = k == 0 && m == 0 ||
q <= m && k >= 0 && (p (k - 1) qs (m - q) || p k qs m)
-- Reinhard Zumkeller, Apr 22 2013
(PARI) list(lim)=my(v=List()); lim\=1; for(z=4, sqrtint(lim\4), for(y=3, min(sqrtint((lim-z^2)\3), z-1), for(x=2, min(sqrtint((lim-y^2-z^2)\2), y-1), for(w=1, min(sqrtint(lim-x^2-y^2-z^2), x-1), listput(v, w^2+x^2+y^2+z^2))))); Set(v) \\ Charles R Greathouse IV, Feb 07 2017
CROSSREFS
KEYWORD
nonn,easy,nice
AUTHOR
STATUS
approved