Derangement Calculator
Enter n to find D(n): the count of permutations of n items where nothing lands in its original spot.
Derangement Calculator
Quick:
Recurrence
D(n) = (n−1) × (D(n−1) + D(n−2))
D(0) = 1 · D(1) = 0
Closed form
D(n) = n! × Σk=0n (−1)k/k!
D(n) — derangements
n = 4
9
n! (total permutations)
24
Probability D(n)/n!
37.500%
Probability converges to 1/e ≈ 36.788% as n → ∞
| k | D(k) | k! | Probability |
|---|
Copied!
Summary
Enter n to find D(n): the count of permutations of n items where nothing lands in its original spot.
How it works
- Enter n — the number of elements in the set.
- The calculator applies the inclusion-exclusion recurrence D(n) = (n-1)(D(n-1) + D(n-2)).
- The exact integer count of valid derangements is shown.
- The probability p = D(n)/n! is displayed (approaches 1/e ≈ 36.79% as n grows).
- A step-by-step table shows D(k) for k = 0 through n.
Use cases
- Probability homework: find the chance that no student gets their own exam back in a random shuffle.
- Secret Santa analysis: calculate how many ways gifts can be assigned so nobody picks themselves.
- Combinatorics proofs: verify inclusion-exclusion results by hand.
- Algorithm design: enumerate or count hat-check permutations.
- Statistics: model matching problems where no element is in its natural position.
- Competitive programming: look up subfactorial values quickly.
Frequently Asked Questions
Last updated: 2026-06-13 ·
Reviewed by Nham Vu