[Math] $n$-permutations with exactly $k$ fixed points

permutations

It's easy to deduce the formula for $n$-permutations with exactly $k$ fixed points. The result is similar to $n$-derangement formula and it's equal to $ D_{n,k}= \frac{n!}{k!}\sum_{i=0}^{n-k}\frac{(-1)^i}{i!}$. But I think it is not convenient. Last time I saw the problem in which you had to write a program that for a given $n,k$ (with even eighteen digits!) count $D_{n,k}$. So I'm wondering is there any better formula for this? Maybe recursive formula, like for $n$-derangements $D_n=n\cdot (D_{n-1}+D_{n-2})$?

Best Answer

Use the fact that $D_{n,k} = ^nC_k.D_{n-k,0}$ and $D_{n,0} = round (\frac{n!}{e})$.

So $D_{n,k} = {n\choose k} \times round (\frac{(n-k)!}{e})$