%I #7 Feb 16 2015 16:16:46
%S 1,8,27,27,8,27,27,8,27,27,27,27,27,64,27,27,64,27,27,64,27,64,64,27,
%T 64,64,27,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,
%U 64,64,64,125,64,64,125,64,64,125,64,125,125,64,125,125,64,125,125,125,125
%N Smallest cube that is the sum of n positive squares.
%C It appears that for n in [k^3+1,(k+1)^3], a(n) is either (k+1)^3 or (k+2)^3. The Mathematica code uses backtracking to find the least cube for each n. - _T. D. Noe_, Jan 03 2005
%e Here are the initial solutions: cube = {list of n numbers whose squares sum to the smallest cube}:
%e 1 = {1}
%e 8 = {2, 2}
%e 27 = {1, 1, 5}
%e 27 = {1, 1, 3, 4}
%e 8 = {1, 1, 1, 1, 2}
%e 27 = {1, 1, 1, 2, 2, 4}
%e 27 = {1, 1, 2, 2, 2, 2, 3}
%e 8 = {1, 1, 1, 1, 1, 1, 1, 1}
%e 27 = {1, 1, 1, 1, 1, 1, 1, 2, 4}
%t $RecursionLimit=1000; try2[lev_] := Module[{t, j, ss}, ss=Plus@@(Take[soln, lev-1]^2); If[lev>n, If[ss<=sumMax&&IntegerQ[ss^(1/3)]&&ss<minSum, minSum=ss; bestSoln={ss, soln}], If[lev==1, t=1, t=soln[[lev-1]]]; j=t; While[ss+(n-lev+1)*j^2<=sumMax, soln[[lev]]=j; try2[lev+1]; soln[[lev]]=t; j++ ]]]; Table[minSum=Infinity; bestSoln={}; sumMax=(Ceiling[n^(1/3)]+1)^3; soln=Table[1, {n}]; try2[1]; bestSoln[[1]], {n, 100}]
%Y Cf. A102313 (least k such that k^3 is the sum of n positive squares).
%K easy,nonn
%O 1,2
%A _Giovanni Teofilatto_, Dec 31 2004
%E Corrected and extended by _T. D. Noe_, Jan 01 2005