login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A102855
Minimal number of distinct nonzero tetrahedral numbers needed to represent n, or -1 if no such representation is possible.
6
1, -1, -1, 1, 2, -1, -1, -1, -1, 1, 2, -1, -1, 2, 3, -1, -1, -1, -1, 1, 2, -1, -1, 2, 3, -1, -1, -1, -1, 2, 3, -1, -1, 3, 1, 2, -1, -1, 2, 3, -1, -1, -1, -1, 2, 3, -1, -1, 3, 4, -1, -1, -1, -1, 2, 1, 2, -1, 3, 2, 3, -1, -1, -1, 3, 2, 3, -1, 4, 3, 4, -1, -1, -1, -1, 2, 3, -1, -1
OFFSET
1,5
LINKS
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