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
Seiichi Manyama, Table of n, a(n) for n = 0..10000
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
KEYWORD
nonn
AUTHOR
Seiichi Manyama, Sep 05 2017
STATUS
approved