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.

A291905 Row sums of A291904.

Original entry on oeis.org

1, 1, 0, 1, 1, 0, 2, 1, 1, 3, 2, 3, 4, 4, 6, 8, 8, 11, 14, 16, 21, 26, 32, 39, 49, 60, 75, 93, 114, 142, 176, 217, 268, 334, 411, 510, 632, 779, 967, 1196, 1477, 1832, 2266, 2801, 3470, 4291, 5310, 6572, 8129, 10061, 12449, 15401, 19058, 23581, 29178, 36102, 44668
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.

Examples

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

Crossrefs

Programs

  • Maple
    b:= proc(n, i) option remember; `if`(n=0, 1, add(
         `if`(j=i, 0, b(n-j, j)), j=max(1, i-1)..min(i+1, n)))
        end:
    a:= n-> b(n, 0):
    seq(a(n), n=0..60);  # Alois P. Heinz, Sep 05 2017
  • Mathematica
    T[0, 0] = 1; T[, 0] = 0; T[n?Positive, k_] /; 0 < k <= Floor[(Sqrt[8n+1] - 1)/2] := T[n, k] = T[n-k, k-1] + T[n-k, k+1]; T[, ] = 0;
    a[n_] := Sum[T[n, k], {k, 0, Floor[(Sqrt[8n+1] - 1)/2]}];
    Table[a[n], {n, 0, 60}] (* Jean-François Alcover, May 29 2019 *)
  • 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) if j != i)
    def a(n): return b(n, 0)
    print([a(n) for n in range(61)]) # Indranil Ghosh, Sep 06 2017, after Maple program