🧮 Brain Teaser

The Permutation That Avoids Its Own Position

Let SnS_n be the set of all permutations of {1,2,…,n}\{1, 2, \ldots, n\}. For a permutation σ∈Sn\sigma \in S_n, say that ii is a fixed point if σ(i)=i\sigma(i) = i.

Now consider all permutations σ∈Sn\sigma \in S_n and look at ∑σ∈Sn(number of fixed points of σ)\sum_{\sigma \in S_n} (\text{number of fixed points of } \sigma).

Compute this sum. Then use it to find the expected number of fixed points of a uniformly random permutation of {1,…,n}\{1, \ldots, n\}.

Does the answer surprise you?

linearity of expectationpermutationsfixed pointscombinatoricselegant surprise

Answer: Expected Fixed Points of a Random Permutation

Key Idea / Intuition

Instead of thinking about each permutation as a whole, swap the order of summation: count, for each position ii, how many permutations fix ii. This linearity trick turns a complicated global count into nn identical easy counts. The surprise is that the expected number of fixed points is exactly 11, regardless of nn — even as n→∞n \to \infty.


Formal Proof / Solution

Step 1: Swap the sum.

\sum_{\sigma \in S_n} (\text{# fixed points of } \sigma) = \sum_{\sigma \in S_n} \sum_{i=1}^n \mathbf{1}[\sigma(i) = i] = \sum_{i=1}^n \sum_{\sigma \in S_n} \mathbf{1}[\sigma(i) = i].

Step 2: Count permutations fixing a given ii.

For a fixed ii, the number of σ∈Sn\sigma \in S_n with σ(i)=i\sigma(i) = i is (n−1)!(n-1)!, since the remaining n−1n-1 elements can be arranged freely.

Step 3: Compute the total.

\sum_{\sigma \in S_n} (\text{# fixed points of } \sigma) = \sum_{i=1}^n (n-1)! = n \cdot (n-1)! = n!.

Step 4: Expected value.

Since there are n!n! permutations total, the expected number of fixed points of a uniformly random permutation is:

\mathbb{E}[\text{# fixed points}] = \frac{n!}{n!} = \boxed{1}.

Why is this beautiful?

The same argument via linearity of expectation is even slicker: let Xi=1[σ(i)=i]X_i = \mathbf{1}[\sigma(i) = i]. Then P(Xi=1)=(n−1)!n!=1n\mathbb{P}(X_i = 1) = \frac{(n-1)!}{n!} = \frac{1}{n}, and

E[∑i=1nXi]=∑i=1n1n=1.\mathbb{E}\left[\sum_{i=1}^n X_i\right] = \sum_{i=1}^n \frac{1}{n} = 1.

The XiX_i are not independent — if σ\sigma fixes 1 and 2, it cannot fix nn if it must be a derangement of the rest — yet their expectations add linearly anyway, giving exactly 1 for all nn. The answer is independent of nn: whether you shuffle 3 cards or 3 million, on average exactly one card lands in its original position.

This is also the starting point for the derangement formula: the probability of no fixed points approaches 1/e≈0.3681/e \approx 0.368 as n→∞n \to \infty, yet the mean never moves from 1.

Source: Mathematical folklore / Putnam warmup

Type: PutnamSource: Mathematical folklore / Putnam warmupEdit on GitHub ↗