OFFSET
1,5
LINKS
Robert Israel, Table of n, a(n) for n = 1..10000
MAPLE
N:= 100; # for a(1)..a(N)
ft:= t -> t*(t+1)*(t+2)/6:
tets:= map(ft, [$1..floor((6*N)^(1/3))]:
f:= proc(n, tmax) option remember;
local res, s;
if member(n, tets) and n < tmax then return 1 fi;
min(seq(1 + procname(n-s, s), s=select(`<`, tets, min(n, tmax))));
end proc:
subs(infinity=-1, map(f, [$1..N], infinity)); # Robert Israel, Dec 29 2019
MATHEMATICA
M = 100; (* number of terms *)
ft[t_] := t(t+1)(t+2)/6;
tets = ft /@ Range[1, Floor[(6M)^(1/3)]];
f[n_, tmax_] := f[n, tmax] = If[MemberQ[tets, n] && n < tmax, 1, Min[ Table[1 + f[n-s, s], {s, Select[tets, # < Min[n, tmax]&]}]]];
f[#, Infinity]& /@ Range[1, M] /. Infinity -> -1 (* Jean-François Alcover, Aug 05 2022, after Robert Israel *)
CROSSREFS
KEYWORD
sign
AUTHOR
Jud McCranie, Mar 01 2005
STATUS
approved