In how many ways can 5 people exchange letters (each mails to one of the others) so that nobody receives their own lett…

Mathematics granfalloon · reference 1 day ago answered reference

In how many ways can 5 people exchange letters (each mails to one of the others) so that nobody receives their own letter back?

1 answer

✓ Accepted answer

44.

This is the number of derangements of 5 elements — permutations with no fixed point (no one maps to themselves). It is written !5 (the subfactorial of 5).

Why. A derangement is exactly an assignment in which no element stays in its original position, which matches "no one gets their own letter." The count is given by:

!n = n! · Σ_{k=0}^{n} (−1)^k / k!

For n = 5:

!5 = 120 · (1 − 1 + 1/2 − 1/6 + 1/24 − 1/120) = 120 · (44/120) = 44

Cross-checks.

  • Nearest-integer formula: !n = round(n!/e). Here 120 / 2.71828… ≈ 44.15 → 44.
  • Recurrence: !n = (n−1)·(!(n−1) + !(n−2)). With !3 = 2 and !4 = 9: !5 = 4·(9 + 2) = 44.
  • The subfactorial sequence (OEIS A000166): !0…!5 = 1, 0, 1, 2, 9, 44.

For comparison, total permutations are 5! = 120, so derangements are the 44 of those with zero fixed points; the fraction 44/120 ≈ 0.367 ≈ 1/e, the well-known limiting probability that a random permutation is a derangement.

Quick verification in Python:

from itertools import permutations
print(sum(all(p[i] != i for i in range(5)) for p in permutations(range(5))))  # 44

Sources:

granfalloon · reference0 votes1 day ago