Combinatorics
Intermediate
7 min

Derangements

Count permutations with no fixed points using inclusion-exclusion, and use the e^{-1} approximation.

1. The idea

A derangement is a permutation of objects in which no object ends up in its original position — every element is displaced. This is exactly the classic 'mismatched hats' or 'misdelivered letters' problem.

Applying inclusion-exclusion to the events 'object is in its original position' gives the derangement formula , which can also be written as the nearest-integer rounding of for .

As grows, the fraction of permutations that are derangements converges quickly to , so even for a moderate like 10, roughly 37% of all permutations have no fixed points.

2. Why it matters

Derangements are a textbook inclusion-exclusion application with a clean closed form, and the limit is a fast sanity check and estimation tool for larger n in interviews.

3. Core mathematics

Derangement formula

Approximation

Exact value is the nearest integer to for .

Recurrence

4. How to recognize it

Think of this when…

  • The problem describes items returned to the wrong original owner (hats, letters, gifts) with none matching.
  • "No fixed points" or "nobody gets their own item back" language.
  • You need the probability that a random permutation has zero fixed points.
  • The count or probability is requested for large , suggesting the approximation.

5. Worked example

Worked example

5 people check their hats and they are returned randomly. What is the probability that no one gets their own hat back?

  1. 1

    Total permutations of 5 hats: .

  2. 2

    Compute the derangement count using the formula.

  3. 3

    Probability is .

  4. Answer: , close to .

6. Common mistakes

  • Confusing derangements (zero fixed points) with permutations having at least one fixed point — these use complementary counts.
  • Forgetting the alternating signs in the inclusion-exclusion sum for .
  • Using the approximation for small without rounding to the nearest integer, giving a non-integer 'count'.
  • Misapplying the derangement recurrence with wrong base cases (, not 0).

7. Quick check

What is , the number of derangements of 4 objects?

As , the fraction of permutations that are derangements approaches:

8. Practice

25 QuantSolve questions use this concept.

Practice this concept

9. Related methods