Find all the numbers and aware A $3$-digit number $n$ is said and aware if the last $ 3$ digits of $n ^ 2$ are the same digits of $n$ and in the same order. Find all the numbers and aware
I solved it with some nasty casework:
We must find all integers $0\leq n < 1000$ such that $n^k \equiv n \pmod{1000}$ for any integer $k$. Actually we only need to check this statement for $k = 2$ because the rest will follow by induction.
Now we can apply the Chinese Remainder Theorem:
For the factor of 8, we easily check by hand that $n^2 \equiv n\pmod{8}$ iff $n\equiv 0\pmod{8}$ or $n\equiv 1\pmod{8}$.
As for the other factor of $125$, we also check that $n^2 \equiv n\pmod{5}$ iff $n\equiv 0\pmod{5}$ or $n\equiv 1\pmod{5}$. Of the integers $n$ with $n \equiv 0 \pmod{5}$, the only integers with $n^2 \equiv n\pmod{25}$ are those with $n\equiv 0\pmod{25}$; similarly, of the integers $n$ with $n \equiv 1 \pmod{5}$, the only integers with $n^2 \equiv n\pmod{25}$ are those with $n\equiv 1\pmod{25}$ (because when we write $n = 5k + 1$, we then find that $n^2 - n \equiv 5k\pmod{25}$, so that $k\equiv 0\pmod{5}$). Of the integers $n$ with $n\equiv 0\pmod{25}$, we know that $n^2 \equiv n\pmod{125}$ only when $n\equiv 0\pmod{125}$; similarly, of the integers $n$ with $n \equiv 1 \pmod{25}$, the only integers with $n^2 \equiv n\pmod{125}$ are those with $n\equiv 1\pmod{125}$ (because when we write $n = 25k + 1$, we then find that $n^2 - n \equiv 25k\pmod{125}$, so that $k\equiv 0\pmod{5}$). Thusly the only solutions to the congruence $n^2 \equiv n\pmod{125}$ are those with $n\equiv 0\pmod{125}$ or $n\equiv 1\pmod{125}$.
So now we know that there are exactly four such integers: $n = 0$ (which corresponds to $n\equiv 0\pmod{8}, n\equiv 0\pmod{125}$), $n = 625$ (which corresponds to $n\equiv 1\pmod{8}, n\equiv 0\pmod{125}$), $n = 376$ (which corresponds to $n\equiv 0\pmod{8}, n\equiv 1\pmod{125}$), and $n = 1$ (which corresponds to $n\equiv 1\pmod{8}, n\equiv 1\pmod{125}$). Now we are done.
We remark in passing that this approach can be applied to other moduli besides $1000$, as long as the modulus is prime-factorized.
Is there a shorter or more enjoyable solution?

There is one very nice thing we can use. It is not a coincidence that 0 and 1 were the only numbers that worked for both modulo 8 and 125. We can prove that quite easily, actually. Let $p^k$ be a prime power. Then:
$$
n^2=n\pmod{p^k}
\iff p^k\mid n^2-n = n(n-1)
\iff p^k \mid n \lor p^k \mid n-1
$$
$$
\iff n\in\{0,1\} \pmod{p^k}
$$
(Do you see why the second "if and only if" is valid?)
With this, we can easily solve any problem asking $n^2=n \pmod m$. Just find the prime factorisation $m=p_1^{\alpha_1}\cdots p_k^{\alpha_k}$. Then $n=0$ or $n=1$ modulo each of the prime powers, giving $2^k$ solutions, which we can find with the Chinese Remainder Theorem.
