TITLE: Smallest cube ending in $2017$
QUESTION [15 upvotes]: What is the smallest cube ending in $2017$?

My try: I know that the only possible units digit is $3$,
$$(a+3)^3 = 2017 \mod 10^4\;$$
and 
$$a^3 + 9a^2 + 27a = 1990\mod 10^4$$
I don't know how to proceed, I tried factoring and adding $10^5$ and $1990$ but when I saw the answer, this approach would take forever.

REPLY [8 votes]: $a^3 + 9a^2 + 27a = 1990\mod 10^4\Longleftrightarrow\cases{a^3 + 9a^2 + 27a = 1990\mod 2^4\\a^3 + 9a^2 + 27a = 1990\mod 5^4\\}$
Now $2^4=16$, so the first equation is easy and happens to have only one solution, $14\bmod 16$.
As for the second, the only solution is $320\bmod 625$.
By the CRT, the only solution modulo $10000$ is $9070$, resulting in the least solution $$9073^3=746883272017$$