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.

A291677 Number of permutations p of [2n] such that 0p has exactly n alternating runs.

Original entry on oeis.org

1, 1, 7, 148, 6171, 425976, 43979902, 6346283560, 1219725741715, 301190499710320, 92921064554444490, 35025128774218944648, 15838288022236083603486, 8462453158197423495502224, 5274234568391796228927038748, 3792391176672742840187796835728
Offset: 0

Views

Author

Alois P. Heinz, Aug 29 2017

Keywords

Examples

			a(2) = 7: 1243, 1342, 1432, 2341, 2431, 3421, 4321.
		

Crossrefs

Cf. A186370.
Bisection (even part) of A303160.

Programs

  • Maple
    b:= proc(n, k) option remember; `if`(k=0,
          `if`(n=0, 1, 0), `if`(k<0 or k>n, 0,
           k*b(n-1, k)+b(n-1, k-1)+(n-k+1)*b(n-1, k-2)))
        end:
    a:= n-> b(2*n, n):
    seq(a(n), n=0..20);
  • Mathematica
    b[n_, k_] := b[n, k] = If[k == 0, If[n == 0, 1, 0], If[k < 0 || k > n, 0, k*b[n - 1, k] + b[n - 1, k - 1] + (n - k + 1)*b[n - 1, k - 2]]];
    a[n_] := b[2*n, n]; Table[a[n], {n, 0, 20}] (* Jean-François Alcover, May 30 2019, after Alois P. Heinz *)
  • Python
    from sympy.core.cache import cacheit
    @cacheit
    def b(n, k): return (1 if n==0 else 0) if k==0 else 0 if k<0 or k>n else k*b(n - 1, k) + b(n - 1, k - 1) + (n - k + 1)*b(n - 1, k - 2)
    def a(n): return b(2*n, n)
    print([a(n) for n in range(31)]) # Indranil Ghosh, Aug 30 2017

Formula

a(n) = A186370(2n,n).
a(n) ~ c * d^n * n! * (n-1)!, where d = 3.4210546206711870249402157940795853513... and c = 0.32723781013647536133280275922604008889245... - Vaclav Kotesovec, Apr 29 2018