Derangement Calculator

!n = permutations with no fixed points

CalculatorsFreeNo Signup
4.5(650 reviews)
All Tools

Loading tool...

About Derangement Calculator

A derangement calculator computing D(n) = n!·Σ(−1)ᵏ/k! — permutations where no element stays in its original position. Shows exact count, probability D(n)/n!, and the inclusion-exclusion formula. All calculations are client-side.

Derangement Calculator Features

  • D(n)
  • Probability
  • Recurrence
  • Table
  • Formula
Derangement: permutation with no fixed points. D(n) = n!·Σₖ₌₀ⁿ(−1)ᵏ/k! ≈ n!/e. Recurrence: D(n) = (n−1)(D(n−1)+D(n−2)). D(0)=1, D(1)=0. Probability → 1/e ≈ 0.3679 as n→∞.

How to Use

Enter n:

  • n: Number of elements
  • D(n): Derangement count
  • P: Probability

Formula

Inclusion-exclusion: D(n) = Σₖ₌₀ⁿ(−1)ᵏC(n,k)(n−k)! = n!Σ(−1)ᵏ/k!. Nearest integer: D(n) = round(n!/e). Also: D(n) = (n−1)(D(n−1)+D(n−2)).

Applications

  • Hat-check problem
  • Secret Santa assignments
  • Card shuffling analysis
  • Cryptographic permutations

Step-by-Step Instructions

  1. 1Enter n.
  2. 2Get D(n).
  3. 3View probability.
  4. 4See recurrence.
  5. 5Check table.

Derangement Calculator — Frequently Asked Questions

What is the hat-check problem?+

n people check hats, hats returned randomly. Probability no one gets their own hat = D(n)/n! → 1/e ≈ 36.79%. Remarkably, this limit is reached very quickly: already for n=4, P ≈ 0.375 (exact: 3/8). The answer is essentially independent of n!

Why does D(n)/n! → 1/e?+

D(n)/n! = Σₖ₌₀ⁿ(−1)ᵏ/k! which is the partial sum of the Taylor series for e⁻¹. As n→∞, this converges to 1/e. The convergence is extremely fast because k! grows so rapidly.

How is the recurrence derived?+

Element 1 goes to position j (n−1 choices). Either j goes to 1 (giving D(n−2) for the rest) or j doesn't go to 1 (equivalent to deranging n−1 elements with j 'pretending' to be 1). So D(n) = (n−1)(D(n−1)+D(n−2)).

Share this tool: