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.

A291896 Number of 1-dimensional sandpiles with n grains piling up against the wall.

Original entry on oeis.org

1, 1, 1, 2, 3, 5, 9, 14, 24, 40, 67, 112, 186, 312, 520, 868, 1449, 2417, 4034, 6730, 11229, 18735, 31254, 52143, 86989, 145119, 242096, 403871, 673751, 1123964, 1875014, 3127926, 5218034, 8704769, 14521354, 24224601, 40411595, 67414781, 112461579, 187608762
Offset: 0

Views

Author

Seiichi Manyama, Sep 05 2017

Keywords

Comments

Number of compositions of n where the first part is 1 and the absolute difference between consecutive parts is <=1 (smooth compositions).

Examples

			The a(6)=9 smooth compositions of 6 are:
:
: oooooo|
:
:     o|
: ooooo|
:
:    o |
: ooooo|
:
:   o  |
: ooooo|
:
:  o   |
: ooooo|
:
:   oo|
: oooo|
:
:  o o|
: oooo|
:
:  oo |
: oooo|
:
:   o|
:  oo|
: ooo|
		

Crossrefs

Programs

  • Maple
    b:= proc(n, i) option remember; `if`(n=0, 1,
          add(b(n-j, j), j=max(1, i-1)..min(i+1, n)))
        end:
    a:= n-> b(n, 0):
    seq(a(n), n=0..50);  # Alois P. Heinz, Sep 05 2017
  • Mathematica
    b[n_, i_] := b[n, i] = If[n==0, 1, Sum[b[n-j, j], {j, Max[1, i-1], Min[i+1, n]}]]; a[n_] := b[n, 0]; Table[a[n], {n, 0, 50}] (* Jean-François Alcover, May 29 2019, after Alois P. Heinz *)
  • Python
    from sympy.core.cache import cacheit
    @cacheit
    def b(n, i): return 1 if n==0 else sum(b(n - j, j) for j in range(max(1, i - 1), min(i + 1, n) + 1))
    def a(n): return b(n, 0)
    print([a(n) for n in range(51)]) # Indranil Ghosh, Sep 06 2017, after Maple code