Derangement Calculator
Count the derangements of n items, the orderings in which no item stays in its original place, and see what share of all orderings they make up. Results are exact for n up to 170.
1 Fill in the box
2 Your answer
Your answer shows here as you type.
How to use the Derangement Calculator
- Enter the number of items n, from 0 to 170.
- Read the count of derangements, the total number of orderings, and the share of orderings with no fixed item.
- Compare the share with 1/e, which is about 36.79 percent, the value it approaches as n grows.
Frequently asked questions
What is a derangement?
A derangement is a permutation of a set in which no element stays in its original position. For example, of the 6 orderings of 3 items, only 2 move every item, so D(3) = 2.
How do you calculate the number of derangements?
D(n) = n! × (1 − 1/1! + 1/2! − 1/3! + ... + (−1)^n/n!). Equivalently, D(0) = 1, D(1) = 0, and D(n) = (n − 1) × (D(n − 1) + D(n − 2)) for n of 2 or more.
What fraction of permutations are derangements?
The fraction D(n)/n! is close to 1/e, about 0.3679 or 36.79 percent, and it gets closer as n grows. For n of 1 or more, D(n) is the nearest whole number to n!/e.
Why is D(1) equal to 0?
With one item, the only ordering leaves that item in its original place, so no derangement exists.
Wrote something with AI? Slop Monkey rewrites it so it sounds like you, and keeps your facts.