5. Matija wrote down all natural numbers from 1 to 2006 in a row. Then, under each number, he wrote down the sum of its digits in a second row. What is the sum of the numbers $v$ in the second row?

# 50th Mathematical Competition for High School Students in Slovenia

Optional Competition, March 29, 2006

## Solutions to the Problems

Each problem is worth 7 points. All mathematically and logically correct solutions are equally valid. When evaluating each problem, reasonably consider the provided scoring guide. A competitor should not receive more than 3 points for a partial solution to a problem if the path to the final solution is not evident from the partial solution.
IV/5. Let's see how many times each digit appears in the first row. First, let's count how many nines there are in the numbers from 1 to 999. The easiest way to do this is to count the numbers with exactly one nine, exactly two nines, and exactly three nines.

If we have exactly one nine, we can place it in the first, second, or third position. For the remaining two positions, we can place any digit from 0 to 8, which gives us 9 options for each position. Thus, we have 3 possible choices for the position of the nine, and once it is placed, we have \(9 \cdot 9\) options for the other digits. In total, this gives us \(3 \cdot 9 \cdot 9 = 243\) nines.

Two nines can be placed in three positions in 3 ways, and on the remaining position, we can place any digit from 0 to 8, so there are \(2 \cdot 3 \cdot 9 = 54\) nines in such numbers. The number 999 has three nines.

Thus, there are exactly \(243 + 54 + 3 = 300\) nines in the numbers from 1 to 999, and this is how many times each other digit appears. In the numbers from 1000 to 1999, there are also 300 twos, threes, ..., and one more thousand ones. The sum of the digits that appear in the numbers from 1 to 1999 is thus

\[
1000 + 2 \cdot 300 \cdot (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9) = 28000
\]

The sum of the digits from the number 2000 to 2006 is \(2 + 3 + 4 + 5 + 6 + 7 + 8 = 35\). The sum of the numbers in the second row is 28035.

Second solution. Let \(S(n)\) denote the sum of the digits of the number \(n\). We observe: if \(m + n = 1999\), then \(S(m) + S(n) = 1 + 9 + 9 + 9 = 28\). Let's show that this is true. We can assume that \(m\) is a three-digit number and \(n\) is a four-digit number. Write \(m\) as \(m = \overline{m_1 m_2 m_3}\). Then \(n = 1999 - \overline{m_1 m_2 m_3} = 1000 + (9 - m_1) \cdot 100 + (9 - m_2) \cdot 10 + (9 - m_3)\). Since \(0 \leq 9 - m_i \leq 9\), the digits of \(n\) are \(1, 9 - m_1, 9 - m_2\), and \(9 - m_3\), so \(S(m) + S(n)\) is indeed 28.

There are \(\frac{1998}{2} + 1 = 1000\) different pairs of numbers \(m\) and \(n\) whose sum is 1999 (the number 1999 is paired with 0), so the desired sum is

\[
\begin{aligned}
100 \cdot 28 + S(2000) + S(2001) & + S(2002) + S(2003) + S(2004) + S(2005) + S(2006) \\
& = 28000 + 35 = 28035
\end{aligned}
\]

![](https://cdn.mathpix.com/cropped/2024_06_07_fb5898f0472fc84ca82bg-13.jpg?height=48&width=1625&top_left_y=1478&top_left_x=221)
Counting individual digits in the numbers from 1000 to 1999 ..................... 2 points Sum of the digits in the numbers from 2000 to 2006 .........................................................................................

Solution: the sum of the numbers in the second row is 28035 ............................................................


[^0]:    Observing that only three numbers cycle ........................................................ 2 points

    ![](https://cdn.mathpix.com/cropped/2024_06_07_fb5898f0472fc84ca82bg-09.jpg?height=49&width=1633&top_left_y=1643&top_left_x=220)

    Concluding that the 100th position is the number \(1956 - x\) and calculating \(x = 1856 \ldots \ldots \ldots \ldots \ldots 2\) points

    Answer: the first position is the number 100, and the 99th position is the number \(1856 \ldots \ldots .1\) point