Automorphic Numbers
A number whose square ends with the same digits as the number is called automorphic number.
The non-trivial (not $0$ and $1$) single digit automorphic numbers are $5$ and $6$. We will see here how to find automorphic numbers ending with either of these two digits.
$\underline{Automorphic\ Numbers\ Ending\ With\ 5}$
If an $n$-digit automorphic number $N$ ends with $5$, that is the number is of the form
$N = d_{n-1}d_{n-2}...d_15$, then
$N^2 = ...a_{n+1}a_nd_{n-1}d_{n-2}...d_15$
The next $(n+1)$-digit automorphic number, ending with $5$, will have the most significant digit
$d_n = a_n$
Thus,
$5^2 = 25$
$25^2 = 625$
$625^2 = 390625$
$0625^2 = 390625$
$90625^2 = 8212890625$
$890625^2 = 793212890625$
$...$
$\underline{Automorphic\ Numbers\ Ending\ With\ 6}$
Similarly, if an $n$-digit number $M$ ends with $6$, that is,
$M = d_{n-1}d_{n-2}...d_16$, then
$M^2 = b_{n+1}b{n}d_{n-1}d_{n-2}...d_16$
-----------book page break-----------
The next $(n+1)$-digit automorphic number, ending with $6$ will have the most significant digit $d_n$ as:
$d_n = 10 - b_n\ (mod\ 10)$
$6^2 = \textcolor{blue}{\underline{3}}6$ [$10 - \textcolor{blue}{3}\ (mod\ 10) = 7$, therefore the next automorphic number ending with $6$ is $76$]
$76^2 = 5\textcolor{blue}{\underline{7}}76$ [$10 - \textcolor{blue}{7}\ (mod\ 10) = 3$, therefore the next automorphic number ending with $6$ is $376$]
$376^2 = 14\textcolor{blue}{\underline{1}}376$ [$10 - \textcolor{blue}{1}\ (mod\ 10) = 9$, therefore the next automorphic number ending with $6$ is $9376$]
$9376^2 = 879\textcolor{blue}{\underline{0}}9376$ [$10 - \textcolor{blue}{0}\ (mod\ 10) = 0$, therefore the next automorphic number ending with $6$ is $09376$]
$09376^2 = 87\textcolor{blue}{\underline{9}}09376$ [$10 - \textcolor{blue}{9}\ (mod\ 10) = 1$, therefore the next automorphic number ending with $6$ is $109376$]
$109376^2 = 1196\textcolor{blue}{\underline{3}}109376$
$...$
In both the series above we are adding one more digit to the previous automorphic number to get the next automorphic number.
Therefore, if we allow $0$ as a significant digit, the for each $n \ge 1$, there are exactly two $n$ digit numbers that are automorphic.