The OEIS mourns the passing of Jim Simons and is grateful to the Simons Foundation for its support of research in many branches of science, including the OEIS.
login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A102855 Minimal number of distinct nonzero tetrahedral numbers needed to represent n, or -1 if no such representation is possible. 6

%I #11 Aug 05 2022 07:42:42

%S 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 -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 -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 Minimal number of distinct nonzero tetrahedral numbers needed to represent n, or -1 if no such representation is possible.

%H Robert Israel, <a href="/A102855/b102855.txt">Table of n, a(n) for n = 1..10000</a>

%p N:= 100; # for a(1)..a(N)

%p ft:= t -> t*(t+1)*(t+2)/6:

%p tets:= map(ft, [$1..floor((6*N)^(1/3))]:

%p f:= proc(n,tmax) option remember;

%p local res, s;

%p if member(n, tets) and n < tmax then return 1 fi;

%p min(seq(1 + procname(n-s,s), s=select(`<`,tets,min(n,tmax))));

%p end proc:

%p subs(infinity=-1,map(f, [$1..N],infinity)); # _Robert Israel_, Dec 29 2019

%t M = 100; (* number of terms *)

%t ft[t_] := t(t+1)(t+2)/6;

%t tets = ft /@ Range[1, Floor[(6M)^(1/3)]];

%t 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 f[#, Infinity]& /@ Range[1, M] /. Infinity -> -1 (* _Jean-François Alcover_, Aug 05 2022, after _Robert Israel_ *)

%Y Cf. A104246, A102795-A102806, A102856-A102858.

%K sign

%O 1,5

%A _Jud McCranie_, Mar 01 2005

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified May 24 15:20 EDT 2024. Contains 372778 sequences. (Running on oeis4.)