Find a probability mass function of a random variable 
$\color{red}{Attempt} $
We start with $k=1$, $P(X=1)$ is the probability that one letter have been put in the correct envelope. Our sample space size is $n$ and since there is only one way that one letter must have been put into the correct envelope and the rest $n-1$ incorrectly and so we see that $P(X=1)= \dfrac{(n-1)!}{n}$, now for $P(X=2)$ it becomes more complicated, so far I know that ${n \choose 2}$ is the size of the sample space and now we want to count the number of ways in which 2 letters must have been put in the correct envelope. First, of all, the $n-2$ letters that have been put incorrectly we have to count them and we have $(n-2)!$ and then the 2 letters that are put correctly this is done in one way thus 
$$ P(X=2) = \frac{(n-2)!}{{n \choose 2} }$$
so, in general, we have 
$$ P(X=k) = \frac{(n-k)!}{n \choose k } $$
is this correct?
 A: For $n$ letters there are $n!$ ways to put them in the envelopes, and the number of ways to put them in such that exactly $k$ letters are in the correct envelope can be divided into two factors:


*

*the $\binom nk$ ways to choose the correctly placed letters

*the $S(n-k)$ ways to place the rest of the envelopes so that none of them are in the correct envelope


Thus the probability $P(X=k)$ is $\frac1{k!}\cdot\frac{S(n-k)}{(n-k)!}$ – in particular the expression you derived is wrong.
We now determine $S(n-k)$; write this as $S(m)$. There are $\binom m0(m-0)!$ permutations in all, $\binom m1(m-1)!$ fixing one point, $\binom m2(m-2)!$ fixing two and so on to $m$ fixed points. Then the inclusion/exclusion principle gives the number of permutations with no fixed points as
$$\sum_{i=0}^m(-1)^i\frac{m!}{i!}=m!\sum_{i=0}^m\frac{(-1)^i}{i!}$$
Then we have the simplification
$$P(X=k)=\frac1{k!}\sum_{i=0}^{n-k}\frac{(-1)^i}{i!}$$
$S(n)$ counts what are called derangements of $n$ objects, and is most often denoted $!n$. With this notation we can also write
$$P(X=k)=\frac1{k!}\cdot\frac{!(n-k)}{(n-k)!}$$
