login
Number of terms in the greedy sum for the n-th triangular number.
4

%I #4 May 15 2014 10:15:42

%S 1,2,3,3,2,3,3,3,2,3,3,3,4,2,3,3,3,4,4,2,3,3,3,4,4,3,2,3,3,3,4,4,3,4,

%T 2,3,3,3,4,4,3,4,4,2,3,3,3,4,4,3,4,4,4,2,3,3,3,4,4,3,4,4,4,3,2,3,3,3,

%U 4,4,3,4,4,4,3,4,2,3,3,3,4,4,3,4,4,4

%N Number of terms in the greedy sum for the n-th triangular number.

%C Greedy residues and related numbers are defined at A242284.

%H Clark Kimberling, <a href="/A242285/b242285.txt">Table of n, a(n) for n = 2..2000</a>

%e n ... n(n+1)/2 ... greedy sum for n(n+1)/2

%e 1 .. 1 .......... (undefined)

%e 2 ... 3 .......... 1 = 1

%e 3 ... 6 .......... 4 = 3 + 1

%e 4 ... 10 ......... 10 = 6 + 3 + 1

%e 5 ... 15 ......... 14 = 10 + 3 + 1

%e 6 ... 21 ......... 21 = 15 + 6

%e 7 ... 28 ......... 28 = 21 + 6 + 1

%e 8 ... 36 ......... 35 = 28 + 6 + 1

%t z = 200; s = Table[n (n + 1)/2, {n, 1, z}]; t = Table[{s[[n]], #, Total[#] == s[[n]]} &[DeleteCases[-Differences[FoldList[If[#1 - #2 >= 0, #1 - #2, #1] &, s[[n]], Reverse[Select[s, # < s[[n]] &]]]], 0]], {n, z}]

%t r[n_] := s[[n]] - Total[t[[n]][[2]]];

%t tr = Table[r[n], {n, 2, z}] (* A242284 *)

%t c = Table[Length[t[[n]][[2]]], {n, 2, z}] (* A242285 *)

%t f = 1 + Flatten[Position[tr, 0]] (* A242286 *)

%t f (f + 1)/2 (* A242287 *) (* _Peter J. C. Moses_, May 06 2014 *)

%Y Cf. A242284, A242286, A242287, A241833, A000217.

%K nonn,easy

%O 2,2

%A _Clark Kimberling_, May 10 2014