Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Given a set of $n$ mutually distinct elements, how many permutations are there such that exactly $k$ of the permuted elements stay at the same place?


Let's take the set $\{A,B,C,D\}$. The original permutation is $A,B,C,D$. There are $5$ permutations where exactly $2$ elements remain at their place:


I tried to find a solution by creating a recurrence relation, but I failed. Does anybody know a solution?

share|cite|improve this question
first try to compute the number of elements in the group of permutations of $n$ elements that don't fix any element (i.e. the case where $k=0$). – Louis La Brocante May 29 '12 at 22:47
up vote 1 down vote accepted

This could be answered by the formula of derangements. Choose the points that are going to be fixed, then choose a derangement of the others. There are $\binom nk$ ways to choose the fixed points, and there are precisely $!(n-k)$ (the "de Montmort" numbers are noted !n instead of n! for the factorial, which precisely count the number of derangements), hence you are looking at

$$ \binom nk \times !(n-k). $$

A formula to compute $!n$ is given by

$$ !n = n! \sum_{i=0}^{n} \frac{(-1)^i}{i!}. $$

Hope that helps,

share|cite|improve this answer
There are many other formulas to compute derangements, and the problem is well-known and extensively studied. – Patrick Da Silva May 29 '12 at 22:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.