login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

A291905
Row sums of A291904.
7
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,7
COMMENTS
Number of compositions of n where the first part is 1 and the absolute difference between consecutive parts is 1.
LINKS
EXAMPLE
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|
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 *)
PROG
(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
CROSSREFS
Sequence in context: A291874 A049346 A227310 * A347584 A366398 A365932
KEYWORD
nonn
AUTHOR
Seiichi Manyama, Sep 05 2017
STATUS
approved