OFFSET
2,2
COMMENTS
Greedy residues and related numbers are defined at A242284.
LINKS
Clark Kimberling, Table of n, a(n) for n = 2..2000
EXAMPLE
n ... n(n+1)/2 ... greedy sum for n(n+1)/2
1 .. 1 .......... (undefined)
2 ... 3 .......... 1 = 1
3 ... 6 .......... 4 = 3 + 1
4 ... 10 ......... 10 = 6 + 3 + 1
5 ... 15 ......... 14 = 10 + 3 + 1
6 ... 21 ......... 21 = 15 + 6
7 ... 28 ......... 28 = 21 + 6 + 1
8 ... 36 ......... 35 = 28 + 6 + 1
MATHEMATICA
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}]
r[n_] := s[[n]] - Total[t[[n]][[2]]];
tr = Table[r[n], {n, 2, z}] (* A242284 *)
c = Table[Length[t[[n]][[2]]], {n, 2, z}] (* A242285 *)
f = 1 + Flatten[Position[tr, 0]] (* A242286 *)
f (f + 1)/2 (* A242287 *) (* Peter J. C. Moses, May 06 2014 *)
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Clark Kimberling, May 10 2014
STATUS
approved