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.

A285850 Number of ways n couples can sit in a row such that exactly one couple sits next to each other.

Original entry on oeis.org

0, 2, 8, 288, 15744, 1401600, 183582720, 33223034880, 7939197665280, 2421184409763840, 917547530747904000, 422959572499916390400, 233037523912020826521600, 151234400024881955183001600, 114177664785555609793383628800, 99217287255932372662490234880000
Offset: 0

Views

Author

Max Alekseyev, Apr 28 2017

Keywords

Examples

			For n=2, if the two couples are (1,2) and (a,b), the a(2) = 8 solutions are a12b, a21b, b12a, b21a, 1ab2, 1ba2, 2ab1, 2ba1. - _N. J. A. Sloane_, Apr 28 2017
		

Crossrefs

Cf. A007060.

Programs

  • Maple
    f:= rectoproc({(12*x^3+84*x^2+192*x+144)*a(x+1)+(8*x^3+34*x^2-6*x-108)*a(x+2)+(-4*x^3-42*x^2-147*x-162)*a(x+3)+(x+3)*a(x+4), a(0) = 0, a(1) = 2, a(2) = 8, a(3) = 288},a(x),remember):
    map(f, [$0..50]); # Robert Israel, Apr 28 2017
  • Mathematica
    a007060[n_]:=Sum[(-1)^(n - k) Binomial[n, k] Subfactorial[2k], {k, 0, n}]; a[n_]:=If[n<1, 0, a007060[n] + 2n*a007060[n - 1]]; Table[a[n], {n, 0, 50}] (* Indranil Ghosh, Apr 28 2017 *)
  • Python
    from sympy import binomial, subfactorial
    def a007060(n): return sum([(-1)**(n - k)*binomial(n, k)*subfactorial(2*k) for k in range(n + 1)])
    def a(n): return 0 if n<1 else a007060(n) + 2*n*a007060(n - 1) # Indranil Ghosh, Apr 28 2017

Formula

For n>0, a(n) = A007060(n) + 2*n*A007060(n-1).
For n>1, a(n) = ( (4*n^2 - 8*n + 1)*a(n-1) + (2*n-2)*(2*n-1)*a(n-2) ) * 2*n/(2*n-3).
(12*n^3+84*n^2+192*n+144)*a(n+1)+(8*n^3+34*n^2-6*n-108)*a(n+2)+(-4*n^3-42*n^2-147*n-162)*a(n+3)+(n+3)*a(n+4) = 0. - Robert Israel, Apr 28 2017