Skip to content
D DocNectar

Free Derangement Calculator

Calculate the number of derangements (permutations with no fixed points) of n items.

100% Free No Signup Works on all devices

Built and fact-checked by the DocNectar team — see our editorial standards

Thanks for rating!

Key Features

Instant Calculation

Get accurate results in real time with our optimized algorithm.

Mobile Friendly

Fully responsive design. Works on all devices & screen sizes.

Privacy Focused

Your data stays on your device. We don't store any inputs.

100% Free

No hidden costs. This tool is completely free forever.

A derangement is a permutation where absolutely no item ends up in its original position — the classic example being the "hat-check problem," where nobody gets their own hat back. This calculator finds the number of derangements of n items using the standard recurrence relation, with a full step-by-step solution.

How it works

Enter the number of items, n. The calculator applies the derangement recurrence !n = (n-1)(!(n-1) + !(n-2)), starting from the base cases !0 = 1 and !1 = 0, building up to n.

  1. Enter number of items (n).
  2. Click Calculate to see your results.

Examples

Derangements of 4 items

For n = 4, there are 9 derangements out of 24 total permutations — a probability of 37.5% that a random shuffle deranges every item.

Who should use it

  • Solving combinatorics and probability problems involving the hat-check problem or similar "no fixed points" scenarios.
  • Teaching or learning recurrence relations in a discrete math course.

Industry applications

  • Combinatorics and discrete mathematics education
  • Probability theory and statistics

Advantages

  • Uses the exact recurrence relation rather than an approximation, giving an exact integer result.
  • Reports the probability of a random permutation being a derangement alongside the count.

Limitations

  • Grows extremely fast — results for larger n become very large integers quickly.

Common mistakes to avoid

  • Confusing derangements with all permutations — a derangement specifically requires that no item remains in its original position.
  • Using the wrong base cases in the recurrence, which throws off every subsequent value.

Best practices

  • For quick approximate estimates at larger n, remember that !n / n! converges to about 1/e, without needing the full recurrence.

Tips

  • The derangement probability !n/n! stabilizes near 36.8% for n as small as 6 or 7, so it's a useful mental shortcut for moderate-sized problems.

Frequently asked questions

Yes, with no signup and no limit on how many calculations you run.
A classic combinatorics problem asking: if n people check their hats and hats are returned at random, what's the probability that nobody gets their own hat back? That count of "nobody gets their own back" arrangements is exactly the derangement number.
With zero items there's exactly one (trivial, empty) arrangement, so !0 = 1 by convention; with one item, that single item can only go back in its own position, so there are zero derangements, making !1 = 0.
The ratio !n / n! quickly converges toward 1/e (about 36.8%), meaning for larger n, roughly a third of all random permutations happen to be complete derangements.

Get new calculators and guides in your inbox

No spam — just new tools like Derangement Calculator and practical guides.

Favorites