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.

A117535 Number of ways of writing n as a sum of powers of 3, each power being used at most 4 times.

Original entry on oeis.org

1, 1, 1, 2, 2, 1, 2, 2, 1, 3, 3, 2, 4, 4, 2, 3, 3, 1, 3, 3, 2, 4, 4, 2, 3, 3, 1, 4, 4, 3, 6, 6, 3, 5, 5, 2, 6, 6, 4, 8, 8, 4, 6, 6, 2, 5, 5, 3, 6, 6, 3, 4, 4, 1, 4, 4, 3, 6, 6, 3, 5, 5, 2, 6, 6, 4, 8, 8, 4, 6, 6, 2, 5, 5, 3, 6, 6, 3, 4, 4, 1, 5, 5, 4, 8, 8, 4, 7, 7, 3, 9, 9, 6, 12, 12, 6, 9, 9, 3, 8, 8, 5, 10, 10
Offset: 0

Views

Author

John W. Layman, Mar 27 2006

Keywords

Comments

It seems that this sequence can be calculated by constructing an insertion tree in which the insertion rules depend on the "age" of a term at a particular stage of the calculation. See the link for a discussion of this concept.

Examples

			a(12) = 4 because 12=9+3=9+1+1+1=3+3+3+3=3+3+3+1+1+1.
		

Crossrefs

Cf. A054390.

Programs

  • Maple
    g:= product((1+x^(3^j)+x^(2*(3^j))+x^(3*(3^j))+x^(4*(3^j))), j=0..10): gser:= series(g,x=0,106): seq(coeff(gser,x,n), n=0..103); # Emeric Deutsch, Apr 02 2006
    # second Maple program:
    b:= proc(n, i) option remember; `if`(n=0, 1, `if`(i<0, 0,
          add(`if`(n-j*3^i<0, 0, b(n-j*3^i, i-1)), j=0..4)))
        end:
    a:= n-> b(n, ilog[3](n)):
    seq(a(n), n=0..100);  # Alois P. Heinz, Jun 21 2012
  • Mathematica
    b[n_, i_] := b[n, i] = If[n == 0, 1, If[i < 0, 0, Sum[If[n - j*3^i < 0, 0, b[n - j*3^i, i - 1]], {j, 0, 4}]]]; a[n_] := b[n, Floor[Log[3, n]]]; Table[a[n], {n, 0, 100}] (* Jean-François Alcover, Dec 22 2016, after Alois P. Heinz *)

Formula

G.f.: product((1+x^(3^j)+x^(2*(3^j))+x^(3*(3^j))+x^(4*(3^j))), j=0..infinity). - Emeric Deutsch, Apr 02 2006
For n>=1, a(3*n+2) = a(n); a(3*n+1) = a(n) + a(n-1); a(3*n) = a(n) + a(n-1). - Tom Edgar, Jun 21 2017
G.f. A(x) satisfies: A(x) = (1 + x + x^2 + x^3 + x^4) * A(x^3). - Ilya Gutkovskiy, Jul 09 2019