OFFSET
0,4
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..1000
Wikipedia, Counting lattice paths
Wikipedia, Motzkin number
MAPLE
b:= proc(x, y) option remember; `if`(x=0, [1, 0],
add(`if`(x+j>y, (p-> p+[0, p[1]*(y-j/2)])(
b(x-1, y-j)), 0), j=-1-y..min(1, y)))
end:
a:= n-> b(n, 0)[2]:
seq(a(n), n=0..30);
MATHEMATICA
b[x_, y_] := b[x, y] = If[x == 0, {1, 0},
Sum[If[x + j > y, With[{p = b[x - 1, y - j]}, p +
{0, p[[1]] (y - j/2)}], 0], {j, -1 - y, Min[1, y]}]];
a[n_] := b[n, 0][[2]];
a /@ Range[0, 30] (* Jean-François Alcover, Apr 05 2021, after Alois P. Heinz *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Alois P. Heinz, Mar 06 2020
STATUS
approved