## 46. The Emperor's Soldiers

General Lassalle knew no fear of death. "If a hussar is over 30, it means he often walked with wet pants," the general used to say. Before one brutal battle, he counted his soldiers: the sum of the digits in the number of soldiers was 17. After the battle, he counted the dead and wounded: the sum of the digits in the number of casualties was also 17. Those remaining in the ranks returned with great dignity - they marched in broad ranks of nine men each.

What can you say about this?
46. Suppose first that the number $N$ of General Lassalle's soldiers is less than 10000 (not too restrictive ${ }^{2}$[^29] condition). Let «mсdu» be the number

$$
N=1000 m+100 c+10 d+u
$$

Then by the condition

$$
m+c+d+u=17
$$

The number of killed and wounded

$$
N^{\prime}=\ll m^{\prime} c^{\prime} d^{\prime} u^{\prime} \gg=1000 m^{\prime}+100 c^{\prime}+10 d^{\prime}+u^{\prime},
$$

where

$$
m^{\prime}+c^{\prime}+d^{\prime}+u^{\prime}=17
$$

Therefore,

$$
\left(m-m^{\prime}\right)+\left(c-c^{\prime}\right)+\left(d-d^{\prime}\right)+\left(u-u^{\prime}\right)=0
$$

The number of soldiers remaining in formation after the battle is

$$
\begin{aligned}
& V=N-N^{\prime}=1000\left(m-m^{\prime}\right)+100\left(c-c^{\prime}\right)+10\left(d-d^{\prime}\right)+ \\
&+\left(u-u^{\prime}\right)
\end{aligned}
$$

Subtracting the previous equation from this, we get

$$
V=999\left(m-m^{\prime}\right)+99\left(c-c^{\prime}\right)+9\left(d-d^{\prime}\right)
$$

| ![](https://cdn.mathpix.com/cropped/2024_05_21_fe999c0fe2ad81fc5164g-197.jpg?height=347&width=73&top_left_y=1826&top_left_x=707) | ![](https://cdn.mathpix.com/cropped/2024_05_21_fe999c0fe2ad81fc5164g-197.jpg?height=352&width=78&top_left_y=1824&top_left_x=850) | Number of  exchanges of  greetings |  | Total |
| :---: | :---: | :---: | :---: | :---: |
| 1  2  3  4  5 | 11  10  9  8  7 | 0  1  3  6  10 | 55  45  36  28  21 | 55  46  39  34  31 |

This number is divisible by 9. Therefore, the soldiers remaining in formation could return in rows of nine.