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.

A370253 Number of deranged matchings of 2n people with partners (of either sex) such that at least one person is matched with their spouse.

This page as a plain text file.
%I A370253 #46 Feb 29 2024 11:29:33
%S A370253 0,1,1,7,45,401,4355,56127,836353,14144545,267629139,5601014255,
%T A370253 128455425593,3203605245777,86317343312395,2498680706048191,
%U A370253 77336483434140705,2548534969132415297,89087730603300393443,3292572900736818264015,128281460895447809211529
%N A370253 Number of deranged matchings of 2n people with partners (of either sex) such that at least one person is matched with their spouse.
%H A370253 Alois P. Heinz, <a href="/A370253/b370253.txt">Table of n, a(n) for n = 0..404</a>
%F A370253 a(n) = A001147(n) - A053871(n).
%F A370253 a(n) = Sum_{i=0..n-1} (-1)^(n - i + 1) * binomial(n,i)*A001147(i).
%F A370253 a(n) mod 2 = A057427(n).
%F A370253 a(n) = Sum_{k=1..n} A055140(n,k). - _Alois P. Heinz_, Feb 14 2024
%e A370253 For n=0, there is no matching which has at least one person matched with their original partner.
%e A370253 For n=1, there are only 2 people, so there is only one way to match them and it is with their original partner.
%e A370253 For n=2, we have two couples, A0 with A1, and B0 with B1. Of the three ways to match them [(A0,A1),(B0,B1)], [(A0,B0),(A1,B1)] and [(A0,B1),(A1,B0)], only the first matching has a person matched up with their original partner.
%p A370253 a:= proc(n) option remember; `if`(n<3, signum(n),
%p A370253       (4*n-7)*a(n-1)-2*(2*n^2-10*n+11)*a(n-2)-2*(n-2)*(2*n-5)*a(n-3))
%p A370253     end:
%p A370253 seq(a(n), n=0..20);  # _Alois P. Heinz_, Feb 14 2024
%t A370253 a[n_] := Sum[(-1)^(n-i+1)*Binomial[n, i]*(2i-1)!!, {i, 0, n-1}];
%t A370253 Table[a[n], {n, 0, 20}] (* _Jean-François Alcover_, Feb 29 2024 *)
%o A370253 (Python)
%o A370253 import math
%o A370253 A001147 = lambda i: math.factorial(2*i) // ( 2 ** i * math.factorial(i) )
%o A370253 A370253 = lambda n: int( sum( (-1)**(i+1) * math.comb(n,n-i) * A001147(n-i) for i in range(1,n+1) ) )
%o A370253 print( ", ".join( str(A370253(i)) for i in range(0,21) ) )
%Y A370253 Cf. A001147 (total number of matchings for 2n people).
%Y A370253 Cf. A053871 (number of deranged matchings of 2n people with partners (of either sex) other than their spouse).
%Y A370253 Cf. A055140, A057427.
%K A370253 nonn
%O A370253 0,4
%A A370253 _Sam Coutteau_, Feb 13 2024