cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A287966 Number of Dyck paths of semilength n such that no level has more than two peaks.

Original entry on oeis.org

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

Views

Author

Alois P. Heinz, Jun 03 2017

Keywords

Crossrefs

Column k=2 of A287847.
Cf. A000108.

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

Formula

a(n) = A287847(n,2).
a(n) = A000108(n) for n <= 2.