An integer is automorphic if its square ends with that integer, like 76^{2} = 57**76**. This notion is clearly base-dependent. Ignoring trivial 0 and 1, in base 10 there are two such numbers for any number of digits; they comprise two infinite sequences that can be thought of informally as “infinite” solutions of x^{2} = x, and formally as solutions of this equation in the ring of 10-adic numbers. They are …56259918212890625 and …740081787109376, both recorded in OEIS, as Wolfram MathWorld points out.

There is a difference between these two sequences. The former naturally grows from the single digit 5, by repeatedly squaring and keeping one more digit than we had: 5^{2} = **25**, 25^{2} = **625**, 625^{2}= 39**0625**, 0625^{2} = 3**90625**, 90625^{2} = 8212**890625**, … (One should not get greedy and keep all the digits after squaring: for example, the leading 3 in 390625 is not the digit we want.) The process described above does not work for 6, because 6^{2} = 36 rather than 76. For the lack of a better term, I’ll call the infinite numbers such as …56259918212890625 **autogenerated**.

According to Wikipedia, the number of b-adic solutions of x^{2} = x is 2^{d} where d is the number of distinct prime factors of b. (Another way to put it: there are as many solutions as square-free divisors of the base.) Two of the solutions are trivial: 0 and 1. So, infinite automorphic numbers exist in every base that is not a prime power, and only in those.

Autogenerated numbers are rarer. For example, there are none in base 12. Indeed, the two viable seed digits are 4 and 9: in base 12, 4^{2} is 14 and 9^{2} is 69. But 14 is not automorphic: 14^{2} = 194. With 69 we get a little further: 69^{2} = 3969. But then 969 is not automorphic, and the process stops.

Computer search suggests that autogenerated numbers **exist if and only if the base is 2 mod 4** (and is not 2). Furthermore, there is exactly one autogenerated number for each such base, and its seed is half the base. Some examples, with 20 digits shown in each base:

- … 21314 15515 22213 50213 in base 6
- … 92256 25991 82128 90625 in base 10
- … 8676a 8cba5 7337a a0c37 in base 14
- … aea80 1g4c9 68da4 e1249 in base 18
- … 179aa 1f0e7 igdi8 d185b in base 22
- … b9ofn odpbn 31mm3 h1g6d in base 26
- … f46rg 1jirj r6f3f e1q7f in base 30
- … g2khh vlas5 k7h4h i248h in base 34

And this is how they were computed with Python: brute force search works fine, because unsuccessful candidates drop out very quickly.

```
def baseN(num, b, numerals="0123456789abcdefghijklmnopqrstuvwxyz"):
return ((num == 0) and numerals[0]) or (baseN(num // b, b, numerals).lstrip(numerals[0]) + numerals[num % b])
# from http://stackoverflow.com/a/2267428
target = 100 # number of digits to compute
for b in range(3, 36): # base
for x in range(2, b): # seed digit
mod = b
while x < b**(target-1) and (x**2 - x) % mod == 0:
mod = mod*b
x = x*x % mod
if x >= b**(target-1):
print('Autogenerated number {} in base {}'.format(baseN(x, b), b))
```

I don’t have a proof of the “2 mod 4” claim, but it may well have a proof somewhere already… According to Dave Richeson, the autogenerating property of 5 in base 10 was discussed in a blog post by Foxmaths!, but the blog is private now. It is also stated in their OEIS article as “a(n+1) = a(n)^2 mod 10^(n+1). – Eric M. Schmidt, Jul 28 2012”.