Derangement Explorer

D_n = n!(1 − 1 + 1/2! − 1/3! + … ± 1/n!) — the hat-check problem

D_n = 44
n! = 120
P(derangement) = D_n/n! ≈ 1/e ≈ 0.3679
Hat-check visualization (owner → slot)
D_n and convergence to 1/e
Inclusion-exclusion decomposition
Inclusion-exclusion:
Let A_i = permutations where item i is fixed.
|A_i| = (n-1)!, |A_i ∩ A_j| = (n-2)!, etc.
D_n = n! − C(n,1)(n−1)! + C(n,2)(n−2)! − …
= Σ_{k=0}^{n} (-1)^k · n!/k!
As n→∞: D_n/n! → e^{-1} ≈ 0.36788