The 2,019 lockers of 2,019 students in a school are numbered with the squares of the first 2,019 positive natural numbers, that is, the first locker has the number $1^{2}=1$, the second locker has the number $2^{2}=4$, the third locker has the number $3^{2}=9$, and so on until the last locker which has the number $2,019^{2}=4,076,361$.
![](https://cdn.mathpix.com/cropped/2024_05_01_a50b5476db779c3986d5g-14.jpg?height=252&width=744&top_left_y=1312&top_left_x=529)

a) How many digits were used to paint the numbers on the first hundred lockers?

b) Adding all the numbers on the lockers, what is the units digit of this result?

#
Solution

a) Let's divide into groups by the number of digits:
I) 1 digit: 3 lockers $\left(1^{2}, 2^{2}, 3^{2}\right)$;

II) 2 digits: $9-3=6$ lockers ( $4^{2}$ to $9^{2}$ );

III) 3 digits: $31-9=22$ lockers $\left(10^{2}\right.$ to $\left.31^{2}\right)$;

IV) 4 digits: $99-31=68$ lockers $\left(32^{2}\right.$ to $\left.99^{2}\right)$;
V) 5 digits: only the locker $100^{2}$.

Therefore, $3+2 \cdot 6+3 \cdot 22+4 \cdot 68+5 \cdot 1=358$ digits were painted on the first hundred lockers.

b) The unit digit of the squares of the first 10 lockers are

$$
1,4,9,6,5,6,9,4,1,0
$$

This sequence of digits repeats every 10. Since the sum of one of these sequences ends in 5 and there are, up to $2020^{2}$ (let's consider $2020^{2}$ to have a whole number of sequences and as its unit digit is zero, it does not affect the result) 202 sums that end in 5, when added together, the result ends in 0.