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.

This page as a plain text file.
%I A291677 #21 May 15 2021 06:18:39
%S A291677 1,1,7,148,6171,425976,43979902,6346283560,1219725741715,
%T A291677 301190499710320,92921064554444490,35025128774218944648,
%U A291677 15838288022236083603486,8462453158197423495502224,5274234568391796228927038748,3792391176672742840187796835728
%N A291677 Number of permutations p of [2n] such that 0p has exactly n alternating runs.
%H A291677 Alois P. Heinz, <a href="/A291677/b291677.txt">Table of n, a(n) for n = 0..228</a>
%F A291677 a(n) = A186370(2n,n).
%F A291677 a(n) ~ c * d^n * n! * (n-1)!, where d = 3.4210546206711870249402157940795853513... and c = 0.32723781013647536133280275922604008889245... - _Vaclav Kotesovec_, Apr 29 2018
%e A291677 a(2) = 7: 1243, 1342, 1432, 2341, 2431, 3421, 4321.
%p A291677 b:= proc(n, k) option remember; `if`(k=0,
%p A291677       `if`(n=0, 1, 0), `if`(k<0 or k>n, 0,
%p A291677        k*b(n-1, k)+b(n-1, k-1)+(n-k+1)*b(n-1, k-2)))
%p A291677     end:
%p A291677 a:= n-> b(2*n, n):
%p A291677 seq(a(n), n=0..20);
%t A291677 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]]];
%t A291677 a[n_] := b[2*n, n]; Table[a[n], {n, 0, 20}] (* _Jean-François Alcover_, May 30 2019, after _Alois P. Heinz_ *)
%o A291677 (Python)
%o A291677 from sympy.core.cache import cacheit
%o A291677 @cacheit
%o A291677 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)
%o A291677 def a(n): return b(2*n, n)
%o A291677 print([a(n) for n in range(31)]) # _Indranil Ghosh_, Aug 30 2017
%Y A291677 Cf. A186370.
%Y A291677 Bisection (even part) of A303160.
%K A291677 nonn
%O A291677 0,3
%A A291677 _Alois P. Heinz_, Aug 29 2017