OFFSET
0,3
LINKS
Alois P. Heinz, Table of n, a(n) for n = 0..1026
FORMULA
a(n) = A291883(2n,n).
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 *)
PROG
(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
CROSSREFS
KEYWORD
nonn
AUTHOR
Alois P. Heinz, Sep 05 2017
STATUS
approved