This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A102855 #11 Aug 05 2022 07:42:42 %S A102855 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, %T A102855 -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, %U A102855 -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 %N A102855 Minimal number of distinct nonzero tetrahedral numbers needed to represent n, or -1 if no such representation is possible. %H A102855 Robert Israel, <a href="/A102855/b102855.txt">Table of n, a(n) for n = 1..10000</a> %p A102855 N:= 100; # for a(1)..a(N) %p A102855 ft:= t -> t*(t+1)*(t+2)/6: %p A102855 tets:= map(ft, [$1..floor((6*N)^(1/3))]: %p A102855 f:= proc(n,tmax) option remember; %p A102855 local res, s; %p A102855 if member(n, tets) and n < tmax then return 1 fi; %p A102855 min(seq(1 + procname(n-s,s), s=select(`<`,tets,min(n,tmax)))); %p A102855 end proc: %p A102855 subs(infinity=-1,map(f, [$1..N],infinity)); # _Robert Israel_, Dec 29 2019 %t A102855 M = 100; (* number of terms *) %t A102855 ft[t_] := t(t+1)(t+2)/6; %t A102855 tets = ft /@ Range[1, Floor[(6M)^(1/3)]]; %t A102855 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]&]}]]]; %t A102855 f[#, Infinity]& /@ Range[1, M] /. Infinity -> -1 (* _Jean-François Alcover_, Aug 05 2022, after _Robert Israel_ *) %Y A102855 Cf. A104246, A102795-A102806, A102856-A102858. %K A102855 sign %O A102855 1,5 %A A102855 _Jud McCranie_, Mar 01 2005