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.
$x^3\equiv 7 \pmod {10}$. So $x\equiv 3 \pmod {10}$.
Put $x=10y+3$, and compute $\pmod {100}$. This yields $1000y^3+900y^2+270y+27 \equiv 17 \pmod {100}$. Thus $70y \equiv -10 \pmod {100}$, or equivalently, $7y \equiv -1 \pmod {10}$. Divide by $7$: $y \equiv 7 \pmod {10}$.
Put $y=10z+7$, hence $x=100z+73$. I think you see the pattern now: calculate modulo $1000$, it gives you the $\pmod{10}$ remainder of $z$, and one more iteration gives you the $\pmod {10000}$ remainder of $x$, which is also the smallest solution.
(Solution: $9073$)