$n$ digit integer which keeps the last $n$ digits when squared

There are some numbers which appear at the end of their own square. More formally, these numbers, $k$, are $n$ digit integers such that $$k^2 - k \equiv 0 \pmod {10^n}$$

Trivially, for $1$ digit numbers we have $1 \to 1, 5 \to 25, 6 \to 36$. For $2$ digit numbers, $25 \to 625, 76 \to 5776$, and for $3$ digit numbers we have $376, 625$.

Here's where it gets interesting. The only four digit number is $9,376$. The only five digit numbers is $90,625$. Six digit numbers? $109,376$ and $890,625$. Seven? $7,109,376$ and $2,890,625$. Eight? $87,109,376$ and $12,890,625$. As we go further and further, they always end in $376$ or $625$.

Another possibly significant observation which can be made is that the sum of the two for each $n$ is $10^n + 1$. Note that this is still true for $n = 4$ and $n = 5$ -- $9376 + 0625 = 10001, 90625 + 09376 = 100001$.

I may be able to construct an algebraic argument, but I'm not in the mood for a plethora of ugly variables. Can you help me understand these observations I've made and show, if true, that it holds for all $n$?

If we look at the equation they solve, $$k^2-k\equiv0\pmod{10^n}$$ we see that since the sum of the roots is the negative of the penultimate term (the linear term in this case), the sum of the roots will be $\equiv1\pmod{10^n}$.
• Also since each root is less than $10^n$ and greater than $1$, the sum must be exactly $10^n + 1$. – Robert Israel Mar 14 '14 at 2:13
• Ending in $376$ and $625$ -- is that just CRT at work? – MCT Mar 14 '14 at 2:16
• @user92774: indeed. The last $n-1$ digits of the solutions mod $10^n$ match the digits of the solutions mod $10^{n-1}$, so each term in the sequence just adds a new digit to the left. – robjohn Mar 14 '14 at 2:18