Automorphic number

In mathematics, an automorphic number (sometimes referred to as a circular number) is a natural number in a given number base formula_1 whose square "ends" in the same digits as the number itself. 
Definition and properties.
Given a number base formula_1, a natural number formula_3 with formula_4 digits is an automorphic number if formula_3 is a fixed point of the polynomial function formula_6 over formula_7, the ring of integers modulo formula_8. As the inverse limit of formula_7 is formula_10, the ring of formula_1-adic integers, automorphic numbers are used to find the numerical representations of the fixed points of formula_6 over formula_10. 
For example, with formula_14, there are four 10-adic fixed points of formula_6, the last 10 digits of which are one of these 
Thus, the automorphic numbers in base 10 are 0, 1, 5, 6, 25, 76, 376, 625, 9376, 90625, 109376, 890625, 2890625, 7109376, 12890625, 87109376, 212890625, 787109376, 1787109376, 8212890625, 18212890625, 81787109376, 918212890625, 9918212890625, 40081787109376, 59918212890625, ... .
A fixed point of formula_20 is a zero of the function formula_21. In the ring of integers modulo formula_1, there are formula_23 zeroes to formula_24, where the prime omega function formula_25 is the number of distinct prime factors in formula_1. An element formula_27 in formula_28 is a zero of formula_24 if and only if formula_30 or formula_31 for all formula_32. Since there are two possible values in formula_33, and there are formula_25 such formula_32, there are formula_23 zeroes of formula_24, and thus there are formula_23 fixed points of formula_6. According to Hensel's lemma, if there are formula_4 zeroes or fixed points of a polynomial function modulo formula_1, then there are formula_4 corresponding zeroes or fixed points of the same function modulo any power of formula_1, and this remains true in the inverse limit. Thus, in any given base formula_1 there are formula_23 formula_1-adic fixed points of formula_6.
As 0 is always a zero divisor, 0 and 1 are always fixed points of formula_6, and 0 and 1 are automorphic numbers in every base. These solutions are called trivial automorphic numbers. If formula_1 is a prime power, then the ring of formula_1-adic numbers has no zero divisors other than 0, so the only fixed points of formula_6 are 0 and 1. As a result, nontrivial automorphic numbers, those other than 0 and 1, only exist when the base formula_1 has at least two distinct prime factors. 
Automorphic numbers in base "b".
All formula_1-adic numbers are represented in base formula_1, using A−Z to represent digit values 10 to 35.
Extensions.
Automorphic numbers can be extended to any such polynomial function of degree formula_3 formula_56 with b-adic coefficients formula_57. These generalised automorphic numbers form a tree.
"a"-automorphic numbers.
An formula_58-automorphic number occurs when the polynomial function is formula_59 
For example, with formula_14 and formula_61, as there are two fixed points for formula_62 in formula_63 (formula_64 and formula_65), according to Hensel's lemma there are two 10-adic fixed points for formula_62, 
so the 2-automorphic numbers in base 10 are 0, 8, 88, 688, 4688...
Trimorphic numbers.
A trimorphic number or spherical number occurs when the polynomial function is formula_69 . All automorphic numbers are trimorphic. The terms "circular" and "spherical" were formerly used for the slightly different case of a number whose powers all have the same last digit as the number itself.
For base formula_14, the trimorphic numbers are:
For base formula_71, the trimorphic numbers are: 
Programming example.
def hensels_lemma(polynomial_function, base: int, power: int):
 """Hensel's lemma."""
 if power == 0:
 return [0]
 if power > 0:
 roots = hensels_lemma(polynomial_function, base, power - 1)
 new_roots = []
 for root in roots:
 for i in range(0, base):
 new_i = i * base ** (power - 1) + root
 new_root = polynomial_function(new_i) % pow(base, power)
 if new_root == 0:
 new_roots.append(new_i)
 return new_roots
base = 10
digits = 10
def automorphic_polynomial(x):
 return x ** 2 - x
for i in range(1, digits + 1):
 print(hensels_lemma(automorphic_polynomial, base, i))