Solution

ID: past-exam-of-the-year-1-of-the-computer-science-course-of-the-university-of-oxford/2019/discrete-mathematics-continuous-mathematics-and-probability/3/a/ii/solution

The initial values are and : one element cannot move, while two elements must be swapped.
For , fix one distinguished element, called , and choose its image , in ways. If form a two-cycle, deleting them leaves an arbitrary derangement on the other elements, giving choices.
Otherwise the permutation cycle containing has length at least three. Remove from that cycle, joining its predecessor directly to . No fixed point is created because the predecessor is not . This gives a derangement on elements. Conversely, any such derangement uniquely recovers the original one by inserting immediately before in its cycle. This case contributes choices for each .
The two cases are disjoint and exhaustive, so the derangement recurrence is

New to topics? Read the docs here!