Toolkit 106
Derangements and Inclusion–Exclusion
A derangement is a permutation in which no element is in its original position.
Let D_n denote the number of derangements of 1,2,\dots,n.
Proof
Suppose the permutation is
For each , define
A derangement has no fixed points, so
By the Principle of Inclusion–Exclusion,
If specified elements are fixed, the remaining elements can be permuted in ways. Therefore,
Factoring out gives