cp's OEIS Frontend

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.

A102855 Minimal number of distinct nonzero tetrahedral numbers needed to represent n, or -1 if no such representation is possible.

Original entry on oeis.org

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

Views

Author

Jud McCranie, Mar 01 2005

Keywords

Crossrefs

Programs

  • 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 *)