We wrote to ten of our friends and put the letters into the addressed envelopes randomly. What is the probability that exactly 5 letters end up with the person they were intended for?
The number of possible events is 10!, which is the number of ways we can permute the letters in front of the envelopes arranged in a single row for the purpose of placing them.

A favorable event is considered when 5 out of the 10 letters end up in their correct envelopes, while the other 5 letters are placed in the remaining 5 envelopes in such a way that none of them are in their correct envelopes. The 5 correctly placed letters can be chosen in $\binom{10}{5}$ different ways. In each of these cases, we essentially face the same further task: to determine the number of permutations of the remaining 5 letters - which we will briefly denote by the numbers $1,2,3,4,5$ - in front of their respective envelopes numbered $1,2,3,4,5$ - briefly: places - such that for each number, one place is forbidden and conversely, for each place, one number is forbidden, for example, the number 1 can be in any place except the 1st, and the 1st place can have any number except 1, and so on.

Let's generally call the permutations of the numbers $1,2, \ldots, n$ under these conditions absolute permutations of these numbers, and denote their number by $A_{n}$. Suppose we know the values of $A_{1}, A_{2}, A_{3}$, and $A_{4}$; we will show that $A_{5}$ can be calculated from these.

Place the 5 in one of the smaller numbered places, say the 4th. (This also satisfies the requirement for the number 4.) If we now place the 4 in the 5th place - or in other words, swap the 4 and 5 - our task reduces to the absolute permutation of the numbers $1,2,3$, the number of which is $A_{3}$.

If, however, we do not place the 4 in the 5th place, then we need to form the absolute permutations of the numbers $1,2,3,4$ in the 1st, 2nd, 3rd, and 5th places (the 4 is forbidden from the 5th place for a different reason, i.e., because we have already dealt with such permutations), which gives us $A_{4}$ number of sequences.

Thus, while the 5 is in the 4th place, we get $A_{3}+A_{4}$ absolute permutations, and if the 5 takes any of the 4 allowed places, then $A_{5}=4\left(A_{3}+A_{4}\right)$.

With the same reasoning, $A_{4}=3\left(A_{2}+A_{3}\right)$ and $A_{3}=2\left(A_{1}+A_{2}\right)$, and it is obvious that $A_{1}=0$ and $A_{2}=1$. Therefore, $A_{3}=2, A_{4}=9$, and $A_{5}=44$, so in the problem of shuffling the letters, the number of favorable cases is $\binom{10}{5} \cdot 44$.

The sought probability is

$$
p=\frac{1}{10!}\binom{10}{5} \cdot 44=\frac{10!\cdot 44}{10!5!5!}=\frac{44}{120^{2}}=\frac{11}{3600}=0.0031
$$

(Alternatively: out of 3600 attempts, the desired arrangement is expected to occur 11 times, or 3 times out of 1000.)

Remarks. 1. Similarly, the number $k$ of cases where exactly $j$ letters are correctly placed is:

$$
\begin{aligned}
& j=\quad 0, \quad 1, \quad 2, \quad 3, \quad 4, \\
& k=1334961, \quad 1334960, \quad 667485, \quad 222480, \quad 55650 \\
& j=\quad 5, \quad 6, \quad 7, \quad 8, \quad 9, \quad 10 \\
& k=11088, \quad 1890, \quad 240, \quad 45, \quad 0, \quad 1
\end{aligned}
$$

It is noteworthy that the numbers $k_{0}=A_{10}$ and $k_{1}=10 \cdot A_{9}$ associated with $j=0$ and $j=1$ differ by only 1, so $A_{10}=10 \cdot A_{9}+1$. This is not a coincidence, and we will explain it below.

2. According to the reasoning in the solution, $A_{n}=(n-1)\left(A_{n-1}+A_{n-2}\right)$. Let's write this equation for $A_{2 n}$, $A_{2 n-1}$, ..., $A_{3}$, and multiply the rows corresponding to odd indices by (-1):

$$
\begin{aligned}
& A_{2 n}=(2 n-1) A_{2 n-1}+(2 n-1) A_{2 n-2} \\
&-A_{2 n-1}=-(2 n-2) A_{2 n-2}-(2 n-2) A_{2 n-3} \\
& A_{2 n-2}=(2 n-3) A_{2 n-3}+(2 n-3) A_{2 n-4} \\
& \ldots \ldots \cdots \cdots \cdots \cdots \cdots \cdots \\
&-A_{5}=-4 A_{4}-4 A_{3} \\
& A_{4}=3 A_{3}+3 A_{2} \\
&-A_{3}=-2 A_{2}-2 A_{1}
\end{aligned}
$$

By adding and rearranging, and considering $A_{1}=0$ and $A_{2}=1$,

$$
A_{2 n}=2 n A_{2 n-1}+1
$$

and similarly,

$$
A_{2 n+1}=(2 n+1) A_{2 n}-1
$$

or uniformly,

$$
A_{n}=n \cdot A_{n-1}+(-1)^{n}
$$

3. It is surprising how similar our result is to the relation $P_{n}=n \cdot P_{n-1}$ for permutations. But what does the $(-1)^{n}$ term do, which we are inclined to consider negligible next to the "large" numbers in combinatorics! The first three terms significantly reduce $A_{n}$ compared to $P_{n}$! In the case of $A_{2}=2 \cdot A_{1}+(-1)^{2}$, this term is even the larger of the two, but even so, $A_{2}$ is only half of $P_{2}$; then in the case of $A_{3}=3 \cdot A_{2}-1$, the $(-1)^{3}$ term significantly reduces $A_{3}$, and $A_{3}=P_{3} / 3$. The found $1 / 3$ is the smallest value of the ratio $A_{n} / P_{n}$.

It can be shown - and the submitted solutions worked with this or the reasoning leading to it - that for every $n$,

$$
A_{n}=n!-\frac{n!}{1!}+\frac{n!}{2!}-\frac{n!}{3!}+\ldots+(-1)^{n} \cdot \frac{n!}{n!}
$$

from which

$$
\lim _{n \rightarrow \infty} \frac{A_{n}}{P_{n}}=\frac{1}{e}=0.36 \ldots
$$

where $e$ is the base of the natural logarithm.

4. In the "ancient times" of probability theory, when it only dealt with questions of games of chance, our problem appeared as the game of 13 (French: jeu du treize): how many ways can the 13 cards of one suit of a French deck be arranged (or dealt in sequence from a shuffled deck with eyes closed) so that no card is in its correct position (the jack in the 11th, the queen in the 12th, and the king in the 13th place).