Problem 8.1. Let $s(n)$ denote the sum of all odd digits of the number $n$. For example, $s(4)=0$, $s(173)=11, s(1623)=4$.

Calculate the value of the sum $s(1)+s(2)+s(3)+\ldots+s(321)$.
Answer: 1727.

Solution. We will separately count the sum of odd digits by place value.

## Units place.

Among the numbers from 1 to 321, there are 32 complete tens:

- from 1 to 10;
- from 11 to 20;
- from 21 to 30;

- ...

- from 311 to 320.

In each ten, the sum of the odd digits in the units place is $1+3+5+7+9=25$. Considering also the last number 321 with the digit 1 in the units place, we get that the sum of all odd digits in the units place is

$$
25 \cdot 32 + 1 = 801
$$

## Tens place.

Consider which numbers have odd digits in the tens place.

- The digit 1 in the tens place appears in 40 numbers: from 10 to 19, from 110 to 119, from 210 to 219, from 310 to 319.
- The digit 3 in the tens place appears in 30 numbers: from 30 to 39, from 130 to 139, from 230 to 239.
- The digit 5 in the tens place appears in 30 numbers: from 50 to 59, from 150 to 159, from 250 to 259.
- The digit 7 in the tens place appears in 30 numbers: from 70 to 79, from 170 to 179, from 270 to 279.
- The digit 9 in the tens place appears in 30 numbers: from 90 to 99, from 190 to 199, from 290 to 299. Therefore, the sum of all odd digits in the tens place is

$$
1 \cdot 40 + 3 \cdot 30 + 5 \cdot 30 + 7 \cdot 30 + 9 \cdot 30 = 760
$$

## Hundreds place.

Consider which numbers have odd digits in the hundreds place.

- The digit 1 in the hundreds place appears in 100 numbers: from 100 to 199.
- The digit 3 in the hundreds place appears in 22 numbers: from 300 to 321.

Therefore, the sum of all odd digits in the hundreds place is

$$
1 \cdot 100 + 3 \cdot 22 = 166
$$

It remains to find the total sum:

$$
801 + 760 + 166 = 1727
$$