A287966 Number of Dyck paths of semilength n such that no level has more than two peaks.
1, 1, 2, 4, 12, 31, 90, 264, 797, 2402, 7355, 22725, 70573, 220007, 688379, 2160568, 6798020, 21428295, 67644503, 213806475, 676499166, 2142338437, 6789119425, 21527297986, 68292751071, 216737768906, 688082702872, 2185085230180, 6940609839680, 22050162168754
Offset: 0
Keywords
Links
- Alois P. Heinz, Table of n, a(n) for n = 0..1000
- Manosij Ghosh Dastidar and Michael Wallner, Bijections and congruences involving lattice paths and integer compositions, arXiv:2402.17849 [math.CO], 2024. See p. 19.
- Wikipedia, Counting lattice paths
Programs
-
Mathematica
b[n_, k_, j_]:=b[n, k, j]=If[j==n, 1, Sum[b[n - j, k, i] Sum[Binomial[i, m] Binomial[j - 1, i - 1 - m], {m, Max[0, i - j], Min[k, i - 1]}], {i, Min[j + k, n - j]}]]; a[n_]:=If[n==0, 1, m=Min[n, 2]; Sum[b[n, m, j], {j, m}]]; Table[a[n], {n, 0, 50}] (* Indranil Ghosh, Aug 17 2017 *)
-
Python
from sympy.core.cache import cacheit from sympy import binomial @cacheit def b(n, k, j): return 1 if j==n else sum(b(n - j, k, i)*sum(binomial(i, m)*binomial(j - 1, i - 1 - m) for m in range(max(0, i - j), min(k, i - 1) + 1)) for i in range(1, min(j + k, n - j) + 1)) def a(n): if n==0: return 1 m=min(n, 2) return sum(b(n, m , j) for j in range(1, m + 1)) print([a(n) for n in range(51)]) # Indranil Ghosh, Aug 17 2017