Problem 9. In the decimal representation of an even number $M$, only the digits $0, 2, 4, 5, 7$, and 9 are used, and digits can repeat. It is known that the sum of the digits of the number $2M$ is 35, and the sum of the digits of the number $M / 2$ is 29. What values can the sum of the digits of the number $M$ take? List all possible answers.
# Answer: 31.

Solution. Let's denote the sum of the digits of a natural number $n$ by $S(n)$. Notice the following facts, each of which is easy to verify if you add numbers in a column.

Lemma 1. Let $n$ be a natural number. Then the number of odd digits in the number $2n$ is equal to the number of carries when adding $n$ and $n$.

Lemma 2. Let $n$ be a natural number. Then the number of digits in the number $n$ that are greater than or equal to 5 is equal to the number of carries when adding $n$ and $n$.

Lemma 3. Let $n$ and $m$ be natural numbers. Then $S(n+m)=S(n)+S(m)-9k$, where $k$ is the number of carries when adding $n$ and $m$.

Let $N$ be the number of odd digits in the number $M$; according to the condition, $N$ is the number of digits in the number $M$ that are greater than or equal to 5. Notice that then, by Lemma 1, when adding $M/2$ and $M/2$, there were exactly $N$ carries, from which, by Lemma 3, we have $S(M)=2S(M/2)-9N=58-9N$. By Lemma 2, when adding $M$ and $M$, there were also $N$ carries, from which, again by Lemma 3, we have $35=S(2M)=2S(M)-9N$.

Thus, $S(M)=58-9N, 2S(M)=35+9N$, from which $3S(M)=93, S(M)=31$.