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

%I #33 Dec 07 2019 12:18:29

%S 0,2,8,288,15744,1401600,183582720,33223034880,7939197665280,

%T 2421184409763840,917547530747904000,422959572499916390400,

%U 233037523912020826521600,151234400024881955183001600,114177664785555609793383628800,99217287255932372662490234880000

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

%H Robert Israel, <a href="/A285850/b285850.txt">Table of n, a(n) for n = 0..224</a>

%H T. Amdeberhan et al., <a href="https://mathoverflow.net/q/267970">n-distant permutations more than not</a>, MathOverflow, 2017.

%F For n>0, a(n) = A007060(n) + 2*n*A007060(n-1).

%F 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).

%F (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

%e 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

%p 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):

%p map(f, [$0..50]); # _Robert Israel_, Apr 28 2017

%t 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 *)

%o (Python)

%o from sympy import binomial, subfactorial

%o def a007060(n): return sum([(-1)**(n - k)*binomial(n, k)*subfactorial(2*k) for k in range(n + 1)])

%o def a(n): return 0 if n<1 else a007060(n) + 2*n*a007060(n - 1) # _Indranil Ghosh_, Apr 28 2017

%Y Cf. A007060.

%K nonn,easy

%O 0,2

%A _Max Alekseyev_, Apr 28 2017