Quant Memo
Core

Derangements: Nobody Gets Their Own Item

The classic combinatorics puzzle of counting permutations where no item lands in its original position, and why the probability of a total mismatch converges to about 1/e as the number of items grows.

A classic setup: n people write their names on gifts, the gifts get shuffled randomly, and everyone receives one gift. What's the probability that nobody receives their own gift? A permutation with this property — nothing ends up in its original spot — is called a derangement.

Counting derangements directly is fiddly, but inclusion-exclusion gives a clean formula: the number of derangements of n items is n! times the alternating sum 11/1!+1/2!1/3!+±1/n!1 - 1/1! + 1/2! - 1/3! + \dots \pm 1/n!. For n = 4, that's 24×(11+0.50.1667+0.0417)24×0.375=924 \times (1 - 1 + 0.5 - 0.1667 + 0.0417) \approx 24 \times 0.375 = 9 derangements out of 24 total permutations, so the probability nobody gets their own gift is 9/24 = 0.375.

What makes the puzzle memorable is that as n grows, that alternating sum converges extremely fast to 1/e0.36791/e \approx 0.3679, so the probability of a total mismatch settles near 37% regardless of whether there are 10 people or 10,000 — a rare case where a combinatorics answer stops depending on the size of the problem almost as soon as n passes single digits.

The probability that a random permutation of n items leaves nothing in its original position converges rapidly to 1/e0.3681/e \approx 0.368 as n grows, and is already close to that value for n as small as 6 or 7.

Related concepts

Practice in interviews

Further reading

  • Classic interview brainteaser, various sources
ShareTwitterLinkedIn