OFFSET
0,4
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..400
Wikipedia, Counting lattice paths
FORMULA
a(2n) = A303284(2n).
EXAMPLE
a(0) = 1: the empty permutation.
a(1) = 1: 1.
a(2) = 1: 12.
a(3) = 2: 132, 231.
a(4) = 8: 1243, 1324, 1342, 1423, 2314, 2341, 2413, 3412.
a(5) = 22: 12543, 13254, 13542, 14253, 14352, 14532, 15243, 15342, 23154, 23541, 24153, 24351, 24531, 25143, 25341, 34152, 34251, 34521, 35142, 35241, 45132, 45231.
MAPLE
b:= proc(u, o, t) option remember; `if`(u+o=0, 1,
`if`(t>0, add(b(u-j, o+j-1, t-1), j=1..u), 0)+
`if`(o+u>t, add(b(u+j-1, o-j, t+1), j=1..o), 0))
end:
a:= n-> b(n, 0, 1):
seq(a(n), n=0..25);
MATHEMATICA
b[u_, o_, t_] := b[u, o, t] = If[u + o == 0, 1, If[t > 0, Sum[b[u - j, o + j - 1, t - 1], {j, 1, u}], 0] + If[o + u > t, Sum[b[u + j - 1, o - j, t + 1], {j, 1, o}], 0]];
a[n_] := b[n, 0, 1];
Table[a[n], {n, 0, 25}] (* Jean-François Alcover, May 25 2018, translated from Maple *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Alois P. Heinz, Apr 20 2018
STATUS
approved