Generalizing matching problem. Question:  If three letters are placed at random in three envelopes, what is the probability that exactly one letter will be placed in the correct envelope?
Answer: There is exactly one outcome in which only letter $1$ is placed in the correct envelope, namely the outcome in which letter $1$ is correctly placed, letter $2$ is placed in envelope $3$, and letter $3$ is placed in envelope $2$.Similarly there is exactly one outcome in which only letter $2$ is placed correctly,and one in which only letter $3$ is placed correctly. Hence, of the $3!=6$ possible outcomes,$3$ outcomes yield the result that exactly one letter is placed correctly.So, the probability is $\frac{3}{6}=\frac{1}{2}$.
Now, I want to generalize this problem for $n$ letters and $n$ envelopes. 
I think the answer would be $$\frac{n(something)}{n!}$$,but don't know what that $something$ should be. I tried with $(n-2)$, but that doesn't work beyond $n=4$.
Please help me to generalize this problem.
Thank you.
 A: Here's an idea. There are $n$ ways to pick the one which will be correct. You'll then want to count the number of derangements of the remaining $n-1,$ so in general, the answer is $$\frac{!(n-1)\cdot n}{n!}=\frac{!(n-1)}{(n-1)!}$$
A: Let us have n letters corresponding to which there exist n envelopes bearing different addresses. Considering various letters being put in
various envelopes, a match is said to occur if a letter goes into the right envelope. Let us first consider the event
$A_{k}$ when a match occurs at the kth place.
When $A_{k}$ occurs, the kth letter goes to the kth envelope but (n - 1) letters can go to the remaining (n - 1) envelopes in (n - 1)! ways.
Therefore : $P(A_{k}) = \frac{(n - 1)!}{n!} = \frac{1}{n}$. $P(A_{k})$ denotes the probability of the kth match
Let us think of a situation :
$Letter_{i}$ must get into $Envelope_{i}$  ,  $Letter_{j}$  must get into  $Envelope_{j}$.
2 cases arise.
Case 1 : 'n' different objects 1.2 •...• n are distributed at random
in n places marked 1.2 •...• n. Find the probability that none of the objects occupies
the place corresponding to its number.
Case 2 : If n letters are randomly placed in correctly addressed envelopes, What is P(Exactly r letters are placed in correct envelopes)= ?
Solutions :
$E_{i}$ : Denote the Event where that the ith object occupies the ith position corresponding to its number.
Then, the probability 'p' that None of the objects occupies
the place corresponding to its number is given by
$
p = P(\overline{E1}  \cap \overline{E2}  \cap \overline{E3}....  \cap \overline{En}  ) = 1 - P(\text{Atleast one of the objects occupies the place corresponding to its number})= 1 - P(E1 \cup E2\cup E3.... \cup En) = 1 - [\sum_{i=1 }^{n}P(E_{i}) - \sum_{i=1 }^{n}\sum_{j=1 }^{n}P(E_{i} \cap E_{j})....+(-1)^{n-1}P(E_{1} \cap E_{2}\cap E_{3}....... \cap E_{n})  ]= 1 - [\frac{\binom{n}{1}}{n} - \frac{\binom{n}{2}}{n(n-1)} +  \frac{\binom{n}{3}}{n(n-1)(n-2)} - ..... +  \frac{(-1)^{n-1}}{n(n-1)(n-2)...3.2.1} ] = 1- [ 1- \frac{1}{2!} + \frac{1}{3!}-...+\frac{^{(-1)^{(n-1)}}}{n!}]= \frac{1}{2!} - \frac{1}{3!} + \frac{1}{4!} - ........ +  \frac{(-1)^{(n)}}{n!} = \sum_{k = 0 }^{n}\frac{(-1)^{k}}{k!}$
......................................................................
But for large n :
p = $1-1 + \frac{1}{2!} + \frac{1}{3!} + \frac{1}{4!} - ........... = e^{-1}$
And, the Probability of Atleast One match : $1 - p = (1-e^{-1})$
.........................................................................
Therefore, P(None of the n letters goes to the correct envelope ) =  $\sum_{k = 0 }^{n}\frac{(-1)^{k}}{k!}$
The Probability of each of the r letters is in the correct envelope = $\frac{1}{r!}$
If we think, Out of n letters, only r letters are in the correct envelope. Then , the probability that None of the remaining, (n-r) letters are in the correct envelope is given by : $\sum_{k = 0 }^{n-r}\frac{(-1)^{k}}{k!}$
Therefore,
P(Out of n letters exactly r letters go to the Correct envelope) is given by :
$\frac{1}{r!}\sum_{k = 0 }^{n-r}\frac{(-1)^{k}}{k!}$
