We write the numbers $1,2,3, \ldots, 100000$ on a sheet of paper, then replace each number by the sum of its digits, and so on, until each number consists of only one digit. What is the most frequent digit in the resulting list?

## - Counting and Inclusion-Exclusion -

PRINCIPLE OF INCLUSION-EXCLUSION - We denote by $|A|$ the number of objects in a set $A$. If $A, B, C$ are sets, then we have:

$$
\begin{gathered}
|A \cup B|=|A|+|B|-|A \cap B| \\
|A \cup B \cup C|=|A|+|B|+|C|-|A \cap B|-|A \cap C|-|B \cap C|+|A \cap B \cap C|
\end{gathered}
$$

To prove these formulas, the simplest way is to draw potatoes!
Here, it is noted that for any integer $n$, the sum of the digits of $n$ is congruent to $n$ modulo 9. The resulting sequence is therefore periodic: $1,2,3,4,5,6,7,8,9,1,2,3,4, \ldots$ and it ends with a 1, so it is the one that appears most often.