7. Find the smallest positive integer $n$ such that $A_{n}=1+11+111+\ldots+1 \ldots 1$ (the last term contains $n$ ones) is divisible by 45.
Answer: 35.

## Solution.

For the sum $A_{n}$ to be divisible by 45, it must be divisible by 5 and by 9. By the divisibility rule for 5, we get that $n$ must be a multiple of 5. Since any natural number gives the same remainder when divided by 9 as the sum of its digits, $A_{n}$ gives the same remainder when divided by 9 as the sum $1+2+\ldots+n=\frac{n(n+1)}{2}$. Since 9 and 2 have no common divisors, $n(n+1)$ must be divisible by 9. Two consecutive natural numbers cannot both be divisible by 3, so either $n$ or $n+1$ must be divisible by 9. Next, consider the numbers $n$ that are multiples of 5, so that either $n$ or $n+1$ is divisible by 9 (it is obvious that $n \leq 45$).

| $n$ | 5 | 10 | 15 | 20 | 25 | 30 | 35 |
| :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- |
| $n+1$ | 6 | 11 | 16 | 21 | 26 | 31 | 36 |

From the table, we see that the smallest number is $n=35$.