login
Smallest x such that n can be written as n = x^2 + y^2 + z^2 with x >= y >= z >= 0, or -1 if no such x exists.
4

%I #30 Jan 23 2018 04:55:47

%S 0,1,1,1,2,2,2,-1,2,2,3,3,2,3,3,-1,4,3,3,3,4,4,3,-1,4,4,4,3,-1,4,5,-1,

%T 4,4,4,5,4,6,5,-1,6,4,5,5,6,5,6,-1,4,6,5,5,6,6,5,-1,6,5,7,5,-1,6,6,-1,

%U 8,6,5,7,6,7,6,-1,6,6,7,5,6,6,7,-1,8,6,8

%N Smallest x such that n can be written as n = x^2 + y^2 + z^2 with x >= y >= z >= 0, or -1 if no such x exists.

%C a(n) = -1 iff n is in A004215, a(n) >= 0 iff n is in A000378.

%C If we maximize x we get A261904.

%H David Consiglio, Jr., <a href="/A261915/b261915.txt">Table of n, a(n) for n = 0..10000</a>

%H David Consiglio, Jr., <a href="/A261915/a261915.txt">Python Program</a>

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

%e Table showing initial values of n,x,y,z:

%e 0 0 0 0

%e 1 1 0 0

%e 2 1 1 0

%e 3 1 1 1

%e 4 2 0 0

%e 5 2 1 0

%e 6 2 1 1

%e 7 -1 -1 -1

%e 8 2 2 0

%e 9 2 2 1

%e 10 3 1 0

%e 11 3 1 1

%e 12 2 2 2

%e 13 3 2 0

%e 14 3 2 1

%e 15 -1 -1 -1

%e 16 4 0 0

%e 17 3 2 2

%e 18 3 3 0

%e 19 3 3 1

%e 20 4 2 0

%e ...

%Y Cf. A000378, A004215, A005875, A261904.

%Y Analogs for 4 squares: A178786 and A122921.

%K sign

%O 0,5

%A _N. J. A. Sloane_, Sep 11 2015

%E a(17) corrected, more terms from _David Consiglio, Jr._, Sep 11 2015