MathorynMathematical Formula Database

Combinatorics

Derangements

A derangement is a permutation in which no element stays in its original position (for example, nobody gets their own hat back). The ratio !n/n!!n/n! quickly approaches 1/e1/e. It is used in probability puzzles such as the secret-Santa or hat-check problem.

!n=n!∑k=0n(−1)kk!!n=n!\sum_{k=0}^{n}\frac{(-1)^k}{k!}
LaTeX!n=n!\sum_{k=0}^{n}\frac{(-1)^k}{k!}

Variables

!n!n
number of derangements of n objects

Example

Count derangements of 4 objects.

  1. 24(1−1+12−16+124)=12−4+124\left(1-1+\frac12-\frac16+\frac1{24}\right)=12-4+1.

Answer: !4=9!4=9.

Related formulas