OFFSET
0,4
COMMENTS
Number of compositions of n where the first part is 1 and the absolute difference between consecutive parts is <=1 (smooth compositions).
LINKS
Seiichi Manyama, Table of n, a(n) for n = 0..4501
EXAMPLE
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|
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 *)
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))
def a(n): return b(n, 0)
print([a(n) for n in range(51)]) # Indranil Ghosh, Sep 06 2017, after Maple code
CROSSREFS
KEYWORD
nonn
AUTHOR
Seiichi Manyama, Sep 05 2017
STATUS
approved