ARITHMETIC WORKSHEETS

Checking three-item orders with no fixed position

Three items can be reordered in 6 ways, and exactly 2 of those leave no item in its original place. This guide lists them and then checks the count by inclusion and exclusion.

What a derangement is

A derangement is an arrangement of distinct items in which no item sits in the position where it started. Start with three items in positions A, B and C. An ordering such as A, C, B keeps A in the first place, so it is not a derangement. An ordering such as B, C, A moves all three, so it is. The question for three items is how many such orderings exist. Small cases can be settled by listing every possibility, which is the check this page uses, and then compared with a counting argument that scales to larger sets.

Listing all six orders

Three distinct items have 3 factorial orderings, which the permutation calculator reports as 6 for n equal to 3 and r equal to 3. They are A B C, A C B, B A C, B C A, C A B and C B A. Mark which keep a fixed point. A B C keeps all three. A C B keeps A. B A C keeps C. C B A keeps B. That leaves B C A and C A B, in which every item has moved. Exactly 2 of the 6 orders are derangements, and the explicit list is the ground truth against which the counting method is tested.

Why subtracting single cases fails

A natural attempt removes the orderings that fix A, those that fix B and those that fix C. Each set has 2 members, since fixing one item leaves 2 for the other two. Subtracting all three, 6 minus 6, gives 0, which contradicts the 2 derangements we listed. The error is that the sets overlap. The ordering A B C fixes all three items, so it was subtracted three times, and orderings that fix two items must also fix the third. The subtraction took out too much, and the overlaps must be put back.

Adding back the overlaps

Inclusion and exclusion corrects the count in stages. Start with all 6 orderings. Subtract the three single-fixed sets of 2 each, which is 6. Add back the pairs of fixed items. Fixing A and B forces C to stay, so each pair set contains exactly the one ordering A B C, and there are 3 pairs, adding 3. Finally subtract the triple overlap, where all three are fixed, which is 1 ordering. The running total is 6 minus 6 plus 3 minus 1, which is 2. The last two steps equal 3 minus 1, or 2, the corrections shown in the worksheet.

Derangement formula applied to three items

For n items, the number of derangements is n factorial times the sum from k equal to 0 to n of negative 1 to the power k divided by k factorial. For n equal to 3 that is 6 times (1 minus 1 plus one half minus one sixth), which is 6 times one third, equal to 2. The same formula gives 1 for n equal to 2, 0 for n equal to 1, 9 for n equal to 4, 44 for n equal to 5 and 265 for n equal to 6. For n equal to 4 the terms are 24 minus 24 plus 12 minus 4 plus 1, which is 9.

A recurrence and a quick estimate

Derangement counts also satisfy D(n) equal to n minus 1 times D(n minus 1) plus D(n minus 2). With D(1) equal to 0 and D(2) equal to 1, D(3) is 2 times 1, which is 2, and D(4) is 3 times 3, equal to 9, and D(5) is 4 times 11, equal to 44. Another handy fact is that D(n) is the nearest integer to n factorial divided by e, about 2.71828. For n equal to 3, 6 divided by e is 2.207, which rounds to 2. For n equal to 4, 24 divided by e is 8.83, which rounds to 9.

Probability of no match

If items are rearranged at random, the chance that nobody gets their own place is D(n) divided by n factorial. For three items that is 2 out of 6, or one third. For four items it is 9 over 24, equal to 0.375. For five it is 44 over 120, about 0.3667, and the values quickly approach 1 over e, about 0.3679. This is the setting of the classic hat-check problem, where several people receive hats at random. Surprisingly, the chance of at least one correct return stays near 63 percent no matter how large the group is.

Checking with the calculators

The permutation calculator supplies the total number of orderings, such as 6 for three items and 24 for four. The basic calculator handles the inclusion and exclusion arithmetic one step at a time: 6 minus 6 is 0, then adding 3 and subtracting 1, or equivalently 3 minus 1, gives 2. For four items, 24 minus 24 is 0, 12 minus 4 is 8, and adding 1 gives 9. Running the pieces separately makes it easy to see which term causes a mismatch. The explicit listing remains the definitive test for three items. If you want to see the structure for yourself, relabel the items 1, 2 and 3 and write each order as a triple. The derangements are 2, 3, 1 and 3, 1, 2, which are the two cyclic shifts of the original order. For three items the derangements happen to be exactly the cyclic shifts, a feature that stops being true at four items, where 9 derangements exist and only 3 of them are cyclic shifts.

Scope and assumptions

The count assumes distinct items, a fixed original arrangement and the requirement that every item changes position. Problems with repeated items, forbidden positions for only some items, or partial derangements need another model. The page covers three items because the full list fits on one line, which allows the formula to be checked against ground truth. Larger cases rely on the formula, the recurrence or software, and the listing method becomes impractical beyond about six items, where 720 orderings would have to be inspected. Applications of derangements include secret-santa style gift draws, where nobody may draw their own name, and seating changes in which everyone must move to a new chair. For a gift draw among three people, 2 of the 6 equally likely assignments are valid, so a random draw has to be repeated until it lands on one of them.

Reproduce the checks

All three-item permutations

Open the Permutation calculator and enter:

Total items n
3
Positions r
3

Expected output:

Permutations

6

The total includes orders with fixed positions.

After all single-fixed-case subtractions

Open the Basic calculator and enter:

First number
6
Operation
subtract
Second number
6

Expected output:

Result

0

This intermediate needs intersection corrections.

Add back pair intersections then remove triple

Open the Basic calculator and enter:

First number
3
Operation
subtract
Second number
1

Expected output:

Result

2

The corrections yield the two explicitly listed orders.

References and implementation scope

The examples describe the behavior of the linked Computandum tools. A successful local check does not establish that another application accepts the same format or applies the same limits.

Related tasks