# Summing up all $N$ digits automorphic numbers

In mathematics an automorphic number (sometimes referred to as a circular number) is a number whose square "ends" in the same digits as number itself. Thus $5$ is automorphic since $25$ ends in $5$. Similarly, $625^2 = 390625$, so $625$ is also automorphic.

Given an integer $N$. How could we find the sum of all $N$ digit numbers which are automorphic? Obviously I am not looking for brute-forcing.

You may also like to take a look at what I call the inspiration problem. My solution for that is not much of mathematically rigorous, as the option were given and I knew that $25$ is automorphic. I simply subtracted from the options, I got $74,75,76$ and $77$. Again as only $1,5$ and $6$ are one digits automorphic numbers, so $74$ and $77$ could be discarded. Also any number ending with $5$ when squared and we take a modulo by $100$ gives $25$ so $75$ rejected. Hence $76$ is the other number.

However, I guess, this is not exactly a mathematical approach, since if the options are not there I don't think I could had solved it, also having more digits makes things more complicated. Hence,I was thinking if there is any other techniques for this?

• Your linked Wikipedia article has the answer: "For $k$ greater than $1$, there are at most two automorphic numbers with k digits" and "The sum of the two numbers is $10^k + 1$. The smaller of these two numbers may be less than $10^{k-1}$; for example with $k = 4$ the two numbers are $9376$ and $625$. In this case there is only one $k$ digit automorphic number; the smaller number could only form a $k$ digit automorphic number if a leading $0$ were added to its digits." Commented Oct 6, 2011 at 10:56
• Given a multiple choice problem, I see nothing wrong with trying all the possible answers. As you say, that often doesn't give larger understanding, but it solves the task at hand. Commented Oct 6, 2011 at 13:12

$1,6,5$

$76, 25$

$376, 625$

$9376$

$90625$

$109376,890625$

For any $N+1$ digit automorphic number, the last $N$ digits must form an automorphic number. The leading digits of all the $N$-digit automorphic numbers sum to $9$. The sequence begins $11, 101, 1001, 10001-625, 100001-9376, 1000001 \cdots$

For $$k$$ greater than $$1$$, there are at most two automorphic numbers with $$k$$ digits...
The sum of the two numbers is $$10^{ k} +1$$ . The smaller of these two numbers may be less than $$10^{ k−1}$$; for example with $$k=4$$ the two numbers are $$9376$$ and $$625$$. In this case there is only one $$k$$ digit automorphic number; the smaller number could only form a $$k$$ digit automorphic number if a leading $$0$$ were added to its digits.