Introduction
Suppose a group of people each receives one item, and every person must receive something other than the item originally assigned to them. How many complete arrangements meet that rule? This classic counting problem is called a derangement. Its answer is surprising: as the group grows, the fraction of arrangements with no item in its original place settles near 36.8 percent.
What Is a Derangement?
A derangement is an arrangement in which none of the objects occupies its original position. Imagine five labelled cards, numbered 1 through 5. At the start, card 1 is in position 1, card 2 is in position 2, and so on. A rearrangement is a derangement only if every card moves to a different position.
The objects and positions are treated as distinct. That matters: swapping two different cards creates a different arrangement, even if some cards happen to have similar appearances in a real-world version of the problem.
The number of derangements of n distinct objects is commonly written Dn, or sometimes !n. The exclamation-mark notation is unusual because it does not mean a factorial. For comparison, n! counts every possible arrangement, while Dn counts only those with no object left in its original place.
For one object, there is no way to move it to a different position, so D1 = 0. For two objects, they must swap, giving D2 = 1. With three objects, there are two derangements: the three objects can cycle in either direction, so D3 = 2.
Why the Count Is Less Obvious Than It Looks
There are n! ways to arrange n distinct objects. A tempting first step is to remove arrangements that leave at least one object in its original spot. The difficulty is that an arrangement may leave several objects unmoved. If we subtract all arrangements with a fixed object one at a time, those with two fixed objects get subtracted twice, those with three get subtracted three times, and so on.
A fixed point is an object that remains in its original position. Counting derangements is therefore the same as counting permutations, or rearrangements, with zero fixed points. The overlap between arrangements with different fixed points is exactly why a careful counting method is needed.
For example, with four objects, consider arrangements where object 1 stays put and arrangements where object 2 stays put. An arrangement in which both 1 and 2 stay put belongs to both groups. If we simply subtract both groups from the total, that arrangement is removed twice, even though it should be excluded only once.
Inclusion-Exclusion Gives an Exact Formula
The standard solution uses a method called inclusion-exclusion. In plain language, it alternates between subtracting arrangements with specified objects in place and adding back the overlaps that were subtracted too often.
First, start with all n! arrangements. Choose one object that must stay in place: there are n choices, and the other objects can be arranged in (n − 1)! ways. Subtract those arrangements. Next, choose two objects to remain fixed and add those arrangements back, because they were included in two of the groups just subtracted. Continue, alternating subtraction and addition for larger groups of fixed objects.
The resulting formula is:
Dn = n! − C(n, 1)(n − 1)! + C(n, 2)(n − 2)! − C(n, 3)(n − 3)! + … + (−1)nC(n, n)0!
Here, C(n, k), also written “n choose k,” is the number of ways to select k objects from n. Since C(n, k)(n − k)! = n!/k!, the same formula can be written more compactly:
Dn = n! (1 − 1/1! + 1/2! − 1/3! + … + (−1)n/n!)
This exact expression works for any non-negative integer n. It counts arrangements by correcting for every possible overlap among the fixed-position conditions.
A Worked Example with Four Objects
There are 4! = 24 total arrangements of four objects. Applying inclusion-exclusion gives:
D4 = 4! − C(4, 1)3! + C(4, 2)2! − C(4, 3)1! + C(4, 4)0!
D4 = 24 − 24 + 12 − 4 + 1 = 9
So nine of the 24 arrangements leave every object in a different position. The fraction is 9/24, or 37.5 percent. The alternating terms may seem to cancel heavily, but that cancellation is what correctly accounts for arrangements with multiple fixed points.
For five objects, the same formula gives D5 = 44. Since there are 120 total arrangements, the fraction is 44/120, about 36.7 percent. Even at this small size, it is close to the long-run proportion.
A Recurrence Offers Another Way to Count
There is also a useful rule that builds each derangement count from the two preceding counts:
Dn = (n − 1)(Dn−1 + Dn−2)
To see why, focus on the object that goes into the first position. It has n − 1 possible destinations, because it cannot stay in its own position. Choose one of those destinations and call it position j. Two cases then arise.
In the first case, the object originally assigned to position j goes to the first position. Those two objects have effectively exchanged positions, and the remaining n − 2 objects must form a derangement among themselves. This contributes Dn−2 possibilities for each choice of j.
In the second case, the object originally assigned to position j does not go to the first position. The first object and the destination position can be treated as one combined element for the remaining placement problem, leaving a derangement count of Dn−1 for each choice of j. Since there are n − 1 choices for j, the two cases together produce the recurrence.
The initial values D1 = 0 and D2 = 1 make the rule easy to use. It gives D3 = 2, D4 = 9, and D5 = 44. The recurrence is often simpler for calculating a sequence of values, while inclusion-exclusion makes the underlying correction for overlaps especially clear.
The Surprising Probability: About 36.8 Percent
If all n! arrangements are equally likely, the chance of getting a derangement is Dn/n!. Dividing the exact formula by n! leaves:
Dn/n! = 1 − 1/1! + 1/2! − 1/3! + … + (−1)n/n!
As n grows, this alternating sum approaches 1/e, where e is a mathematical constant of about 2.718. Therefore, the proportion of arrangements with no fixed points approaches 1/e, or about 36.8 percent.
This is surprising because the chance does not shrink toward zero as more objects are added. Although there are more positions that could remain unchanged, there are also vastly more total arrangements. The two effects balance in such a way that the proportion settles near a stable value.
The approximation becomes useful for large n: Dn is close to n!/e. In fact, the exact count is the nearest integer to n!/e. This is a convenient estimate, but the inclusion-exclusion formula or recurrence gives the exact answer when needed.
The limit does not mean that the chance is exactly 36.8 percent for every group size. For two objects it is 50 percent, for four it is 37.5 percent, and for five it is about 36.7 percent. Small cases vary; the stable proportion describes what happens as the number of objects becomes large.
Where Derangements Are Useful
Derangements provide a mathematical model for assignment problems with a “no one gets their own” rule. A familiar illustration is a group exchanging labelled gifts, where each person must receive a gift originally assigned to someone else. If all assignments are equally likely and each gift is distinct, the number of acceptable assignments is Dn.
The same structure can describe matching tasks. For instance, imagine n labelled documents being placed into n labelled folders, with the condition that no document goes into its corresponding folder. The count is a derangement if every document is used once and every folder receives exactly one document.
Real situations may have additional rules that change the answer. Some assignments might be forbidden for reasons other than keeping an object in its original position, or objects may not be distinct. In those cases, the basic derangement formula may not apply directly. The value of the concept is that it gives a clear answer to the simplest version of the problem and a foundation for more complicated counting questions.
Common Points of Confusion
A derangement does not require every object to move in a single shared cycle. With four objects, for example, one derangement can consist of two separate swaps. The only requirement is that no object remains in its original position.
It also differs from a shuffle that merely looks mixed. A random-looking arrangement might still contain one or more objects in their original positions. A derangement is defined by a precise condition, not by how disordered the result appears.
Finally, Dn is not the same as the number of ways to choose which objects move. The count includes the full arrangement of all objects, and every object must move. Selecting a set of objects to relocate would be a different problem, because it could leave the remaining objects in place.
Conclusion
A derangement counts arrangements in which every object leaves its original position. Inclusion-exclusion provides an exact formula, while a recurrence offers a quick way to build the counts. The most striking result is that the proportion of derangements approaches 1/e, about 36.8 percent, as the number of objects grows. This simple rule connects everyday assignment puzzles to elegant ideas in combinatorics and probability.

