Paritian

Mathematics

Derangements Calculator (Secret Santa and the Hat-Check Problem)

How many ways n people can each draw somebody else's name, and the chance that a random draw works first time.

Results

Arrangements where nobody gets their own 14,833
All possible arrangements 40,320
Chance that nobody gets their own 36.788 %
Chance that at least one person gets their own 63.212 %
Average number of random draws until one works 2.72
How it changes
Chance that nobody gets their ownNumber of people (or items) 2 – 12. Chance that nobody gets their own: 50 → 36.7879; Limit for large groups (1 ÷ e): 36.7879 → 36.7879Chance that nobody gets their ownLimit for large groups (1 ÷ e)0102030405024681012Number of people (or items)

The dashed line marks the value you entered.

What this tool does

A derangement is a shuffle where nobody ends up in their own place — a Secret Santa draw where no one picks themselves, or hats handed back at random with nobody getting their own. The count is the nearest whole number to n! ÷ e, and the chance is about 1 ÷ e = 36.8 % almost whatever the size of the group: 4 people give 37.5 % and 10 people 36.79 %. So a random draw fails nearly two times in three, and on average you need about 2.7 draws, which is why people redraw until it works. A group of one has no valid arrangement.

Formula

!n = n! Σₖ (−1)ᵏ ÷ k! = round(n! ÷ e) · chance = !n ÷ n! → 1 ÷ e ≈ 36.8 %

Variables

SymbolMeaningUnit
nNumber of people (or items)—
DArrangements where nobody gets their own—
TTAll possible arrangements—
PChance that nobody gets their own%
PAChance that at least one person gets their own%
TRAverage number of random draws until one works—

Worked example

  • Number of people (or items)8
  • Arrangements where nobody gets their own14,833
  • All possible arrangements40,320
  • Chance that nobody gets their own36.788 %
  • Chance that at least one person gets their own63.212 %
  • Average number of random draws until one works2.72

Limitations

  • The calculation runs at full precision and only the display is rounded. If you copy an intermediate value and retype it, small differences can appear.
  • The default values are typical reference figures, not measurements of your situation. Replace them with your own data whenever you have it.