OFFSET
0,3
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..400
Wikipedia, Motzkin number
FORMULA
a(n) = A258309(n,n).
MAPLE
b:= proc(x, y, t, k) option remember; `if`(y>x or y<0, 0,
`if`(x=0, 1, b(x-1, y-1, false, k)*`if`(t, (k*x+y)/y, 1)
+b(x-1, y, false, k) +b(x-1, y+1, true, k)))
end:
a:= n-> b(n, 0, false, n):
seq(a(n), n=0..25);
MATHEMATICA
b[x_, y_, t_, k_] := b[x, y, t, k] = If[y > x || y < 0, 0, If[x == 0, 1, b[x - 1, y - 1, False, k]*If[t, (k*x + y)/y, 1] + b[x - 1, y, False, k] + b[x - 1, y + 1, True, k]]];
a[n_] := b[n, 0, False, n];
Table[a[n], {n, 0, 25}] (* Jean-François Alcover, Jun 10 2017, translated from Maple *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Alois P. Heinz, Aug 31 2015
STATUS
approved