%I #4 May 20 2014 23:48:12
%S 1,1,1,2,2,2,2,2,2,2,2,2,3,3,3,2,2,2,2,3,3,3,3,2,2,2,2,2,3,3,3,3,2,3,
%T 3,2,2,2,2,3,3,3,3,2,3,3,3,3,2,2,2,2,3,3,3,3,2,3,3,3,3,4,4,2,2,2,2,3,
%U 3,3,3,2,3,3,3,3,4,4,2,3,2,2,2,2,3,3
%N Number of terms in the squares-greedy sum for n.
%C Greedy sums and related numbers are defined at A242305.
%H Clark Kimberling, <a href="/A242306/b242306.txt">Table of n, a(n) for n = 2..2000</a>
%e n ... squares-greedy sum for n
%e 1 ... (undefined)
%e 2 ... 1 = 1
%e 3 ... 1 = 1
%e 4 ... 1 = 1
%e 5 ... 5 = 4 + 1
%e 6 ... 5 = 4 + 1
%e 7 ... 5 = 4 + 1
%e 8 ... 5 = 4 + 1
%e 9 ... 5 = 4 + 1
%e 10 .. 10 = 9 + 1
%e 11 .. 10 = 9 + 1
%e 12 .. 10 = 9 + 1
%e 13 .. 13 = 9 + 4
%e 14 .. 14 = 9 + 4 + 1
%t z = 200; s = Table[n^2, {n, 1, z}]; s1 = Table[n, {n, 1, z}]; t = Table[{s1[[n]], #, Total[#] == s1[[n]]} &[DeleteCases[-Differences[FoldList[If[#1 - #2 >= 0, #1 - #2, #1] &, s1[[n]],
%t Reverse[Select[s, # < s1[[n]] &]]]], 0]], {n, z}]
%t r[n_] := s1[[n]] - Total[t[[n]][[2]]];
%t tr = Table[r[n], {n, 2, z}] (* A242305 *)
%t c = Table[Length[t[[n]][[2]]], {n, 2, z}] (* A242306 *)
%t f = 1 + Flatten[Position[tr, 0]] (* A242307 *) (* _Peter J. C. Moses_, May 06 2014 *)
%Y Cf. A242305, A242307, A241833, A000027, A000290.
%K nonn,easy
%O 2,4
%A _Clark Kimberling_, May 11 2014