A291885 Number of symmetrically unique Dyck paths of semilength 2n and height n.
1, 1, 5, 31, 252, 2117, 18546, 164229, 1469596, 13229876, 119712521, 1087573357, 9914033252, 90633332870, 830621140260, 7628813061585, 70200092854044, 647070588612140, 5973385906039684, 55217660246861884, 511054426374819184, 4735208302827742549
Offset: 0
Keywords
Links
- Alois P. Heinz, Table of n, a(n) for n = 0..1026
Crossrefs
Cf. A291883.
Programs
-
Maple
b:= proc(x, y, k) option remember; `if`(x=0, 1, `if`(y+1<=min(k, x-1), b(x-1, y+1, k), 0)+`if`(y>0, b(x-1, y-1, k), 0)) end: g:= proc(x, y, k) option remember; `if`(x=0, 1, `if`(y>0, g(x-2, y-1, k), 0)+ `if`(y+1<=k, g(x-2, y+1, k), 0)) end: a:= n-> `if`(n=0, 1, (b(4*n, 0, n) +g(4*n, 0, n) -b(4*n, 0, n-1)-g(4*n, 0, n-1))/2): seq(a(n), n=0..30);
-
Mathematica
b[x_, y_, k_] := b[x, y, k] = If[x == 0, 1, If[y + 1 <= Min[k, x - 1], b[x - 1, y + 1, k], 0] + If[y > 0, b[x - 1, y - 1, k], 0]]; g[x_, y_, k_] := g[x, y, k] = If[x == 0, 1, If[y > 0, g[x - 2, y - 1, k], 0] + If[y + 1 <= k, g[x - 2, y + 1, k], 0]]; a[n_] := If[n == 0, 1, (b[4n, 0, n] + g[4n, 0, n] - b[4n, 0, n - 1] - g[4n, 0, n - 1])/2]; Array[a, 30, 0] (* Jean-François Alcover, May 31 2019, after Alois P. Heinz *)
-
Python
from sympy.core.cache import cacheit @cacheit def b(x, y, k): return 1 if x==0 else (b(x - 1, y + 1, k) if y + 1<=min(k, x - 1) else 0) + (b(x - 1, y - 1, k) if y>0 else 0) @cacheit def g(x, y, k): return 1 if x==0 else (g(x - 2, y - 1, k) if y>0 else 0) + (g(x - 2, y + 1, k) if y + 1<=k else 0) def a(n): return 1 if n==0 else (b(4*n, 0, n) + g(4*n, 0, n) - b(4*n, 0, n - 1) - g(4*n, 0, n - 1))//2 print([a(n) for n in range(31)]) # Indranil Ghosh, Sep 06 2017
Formula
a(n) = A291883(2n,n).