Derangements — find number of permutations where no element is in original position

hard JEE-MAIN JEE-ADVANCED JEE Advanced 2021 3 min read

Question

Find the number of ways to arrange nn distinct objects such that no object is in its original position (derangement). Compute D4D_4 and D5D_5 explicitly.

(JEE Advanced 2021, similar pattern)


Solution — Step by Step

Let AiA_i = set of permutations where element ii IS in its original position. We want the number of permutations where NO element is in its original position:

Dn=n!A1A2AnD_n = n! - |A_1 \cup A_2 \cup \cdots \cup A_n|

By inclusion-exclusion:

A1An=AiAiAj++(1)n+1A1An|A_1 \cup \cdots \cup A_n| = \sum|A_i| - \sum|A_i \cap A_j| + \cdots + (-1)^{n+1}|A_1 \cap \cdots \cap A_n|

Ai|A_i| = permutations fixing element ii = (n1)!(n-1)!. There are (n1)\binom{n}{1} such terms.

AiAj|A_i \cap A_j| = permutations fixing both ii and jj = (n2)!(n-2)!. There are (n2)\binom{n}{2} terms.

In general: (nk)(nk)!\binom{n}{k}(n-k)! for kk fixed elements.

Dn=n!(n1)(n1)!+(n2)(n2)!+(1)n(nn)(0)!D_n = n! - \binom{n}{1}(n-1)! + \binom{n}{2}(n-2)! - \cdots + (-1)^n \binom{n}{n}(0)!

Since (nk)(nk)!=n!k!\binom{n}{k}(n-k)! = \frac{n!}{k!}:

Dn=n!(111!+12!13!++(1)nn!)D_n = n!\left(1 - \frac{1}{1!} + \frac{1}{2!} - \frac{1}{3!} + \cdots + \frac{(-1)^n}{n!}\right) Dn=n!k=0n(1)kk!\boxed{D_n = n! \sum_{k=0}^{n} \frac{(-1)^k}{k!}}
D4=4!(11+1216+124)=24×38=9D_4 = 4!\left(1 - 1 + \frac{1}{2} - \frac{1}{6} + \frac{1}{24}\right) = 24 \times \frac{3}{8} = \mathbf{9} D5=5!(11+1216+1241120)=120×1130=44D_5 = 5!\left(1 - 1 + \frac{1}{2} - \frac{1}{6} + \frac{1}{24} - \frac{1}{120}\right) = 120 \times \frac{11}{30} = \mathbf{44}

Why This Works

The formula is a direct application of inclusion-exclusion. We start with all n!n! permutations and subtract those where at least one element is fixed. The alternating sum corrects for over-counting — permutations with two fixed points get subtracted twice, so we add them back, and so on.

As nn grows large, Dn/n!D_n/n! approaches e10.368e^{-1} \approx 0.368 — so roughly 36.8% of all permutations are derangements, regardless of how large nn is. This is a surprising and elegant result.

The small values worth memorising: D1=0D_1 = 0, D2=1D_2 = 1, D3=2D_3 = 2, D4=9D_4 = 9, D5=44D_5 = 44.


Alternative Method — Recurrence relation

Derangements satisfy two useful recurrences:

Dn=(n1)(Dn1+Dn2)D_n = (n-1)(D_{n-1} + D_{n-2}) Dn=nDn1+(1)nD_n = nD_{n-1} + (-1)^n

The first says: element 1 goes to position jj ((n1)(n-1) choices). Then either element jj goes to position 1 (and the remaining n2n-2 elements form a derangement: Dn2D_{n-2}), or element jj does NOT go to position 1 (equivalent to a derangement of n1n-1 elements: Dn1D_{n-1}).

For JEE, the derangement formula is frequently tested in disguised forms: “letters in wrong envelopes,” “hats returned to wrong people,” “matching problems.” Whenever a problem says “no element in its correct position,” think derangement. The formula Dn=n!(11+1/2!1/3!+)D_n = n!(1 - 1 + 1/2! - 1/3! + \cdots) can be quickly computed for small nn.


Common Mistake

Students sometimes confuse DnD_n with “number of permutations with at least one element NOT in its position” — which is almost all permutations (n!1n! - 1 for n2n \geq 2). Derangements require that ALL elements are displaced, not just some. The question phrasing matters: “no element in its original position” means derangement, while “at least one element displaced” is a different (and much simpler) problem.

Want to master this topic?

Read the complete guide with more examples and exam tips.

Go to full topic guide →

Try These Next