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.

A288743 Number of Dyck paths of semilength n such that the maximal number of peaks per level equals two.

This page as a plain text file.
%I A288743 #17 May 12 2020 04:44:27
%S A288743 1,1,7,18,59,193,616,1955,6244,19926,63490,202068,642816,2044571,
%T A288743 6502193,20673020,65714586,208870774,663868055,2109997964,6706282384,
%U A288743 21315049217,67748772174,215343287489,684507346839,2175916952697,6917096914771,21989855308501
%N A288743 Number of Dyck paths of semilength n such that the maximal number of peaks per level equals two.
%H A288743 Alois P. Heinz, <a href="/A288743/b288743.txt">Table of n, a(n) for n = 2..1000</a>
%H A288743 Wikipedia, <a href="https://en.wikipedia.org/wiki/Lattice_path#Counting_lattice_paths">Counting lattice paths</a>
%e A288743 . a(4) = 7:       /\      /\        /\/\    /\        /\  /\
%e A288743 .            /\/\/  \  /\/  \/\  /\/    \  /  \/\/\  /  \/  \ .
%e A288743 .
%e A288743 .                        /\/\
%e A288743 .             /\/\      /    \
%e A288743 .            /    \/\  /      \  .
%p A288743 b:= proc(n, k, j) option remember; `if`(j=n, 1, add(
%p A288743       b(n-j, k, i)*add(binomial(i, m)*binomial(j-1, i-1-m),
%p A288743        m=max(0, i-j)..min(k, i-1)), i=1..min(j+k, n-j)))
%p A288743     end:
%p A288743 g:= proc(n, k) option remember; add(b(n, k, j), j=1..k) end:
%p A288743 a:= n-> g(n, 2)-g(n, 1):
%p A288743 seq(a(n), n=2..35);
%t A288743 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]}]]; g[n_, k_]:=Sum[b[n, k, j], {j, k}]; Table[g[n, 2] - g[n, 1], {n, 2, 35}] (* _Indranil Ghosh_, Aug 09 2017 *)
%o A288743 (Python)
%o A288743 from sympy.core.cache import cacheit
%o A288743 from sympy import binomial
%o A288743 @cacheit
%o A288743 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))
%o A288743 def g(n, k): return sum(b(n, k, j) for j in range(1, k + 1))
%o A288743 def a(n): return g(n, 2) - g(n, 1)
%o A288743 print([a(n) for n in range(2, 36)]) # _Indranil Ghosh_, Aug 09 2017
%Y A288743 Column k=2 of A287822.
%Y A288743 Cf. A000108.
%K A288743 nonn
%O A288743 2,3
%A A288743 _Alois P. Heinz_, Jun 14 2017