TITLE: Prove that there exists two consecutive natural numbers such that sum of all digits of each number is multiple of $2017$.
QUESTION [6 upvotes]: This is a question in the contest. 

Prove that there exists two consecutive natural numbers such that sum of all digits of each number is multiple of $2017$.

My Solution: I take $a = \underbrace{9\dots 9}_{224}0\underbrace{9\dots 9}_{k}$ such that $2017$ divided $9\times 224 + 9k$ (at least, one can take  $k=2017-224=1793$) and of course $a+1 = \underbrace{9\dots 9}_{224}1\underbrace{0\dots 0}_{k}$ which has sum of digits is $2017$.
My question: I don't think they are the smallest pair but I cannot find another smaller solution. Can someone give me a hint?

REPLY [5 votes]: Let $\Sigma_n$ be the sum of the decimal digits of $n$. Then 
$$\Sigma_{n+1}=\Sigma_{n}+1-9T_n$$ where $T_n$ is the number of trailing nines (because cascaded carries replace all trailing nines by zeroes).
The smallest solution of $9T_n-1=2017k$ is indeed $T_n=1793$ and you can't avoid all these nines.
As the sum of these digits is $1\mod 2017$, a total of $2016=9\cdot224$ is missing. You can't just preprend these $224$ nines, because more carries would result. It suffices to split the last nine to avoid that, and the best way is by moving one unit ahead.
The smalles pair is thus
$$1\underbrace{9\dots 9}_{223}8\underbrace{9\dots 9}_{1793}\to9\cdot2017$$
$$1\underbrace{9\dots 9}_{223}9\underbrace{0\dots 0}_{1793}\to1\cdot2017$$