In mathematics an **automorphic number** (sometimes referred to as a **circular number**) is a number whose square "ends" in the same digits as the number itself. For example, 5^{2} = 2**5**, 6^{2} = 3**6**, 76^{2} = 57**76**, and 890625^{2} = 793212**890625**, so 5, 6, 76 and 890625 are all automorphic numbers. The only automorphic Kaprekar number is 1, because the square of a Kaprekar number cannot start with zero.

The sequence of automorphic numbers begins 1, 5, 6, 25, 76, 376, 625, 9376, ... (sequence A003226 in the OEIS).

Given a *k*-digit automorphic number *n* > 1, an automorphic number *n*′ with at most 2*k*-digits can be found with the formula:

n
′
=
(
3
⋅
n
2
−
2
⋅
n
3
)
mod
10
2
k
.
For *k* greater than 1, there are at most two automorphic numbers with *k* digits, one ending in 5 and one ending in 6. One of them has the form:

n
≡
0
(
mod
2
k
)
,
n
≡
1
(
mod
5
k
)
,
and the other has the form:

n
≡
1
(
mod
2
k
)
,
n
≡
0
(
mod
5
k
)
.
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.

The following digit sequence can be used to find the two *k*-digit automorphic numbers, where *k* ≤ 1000.

12781 25400 13369 00860 34889 08436 40238 75765 93682 19796
26181 91783 35204 92704 19932 48752 37825 86714 82789 05344
89744 01426 12317 03569 95484 19499 44461 06081 46207 25403
65599 98271 58835 60350 49327 79554 07419 61849 28095 20937
53026 85239 09375 62839 14857 16123 67351 97060 92242 42398
77700 75749 55787 27155 97674 13458 99753 76955 15862 71888
79415 16307 56966 88163 52155 04889 82717 04378 50802 84340
84412 64412 68218 48514 15772 99160 34497 01789 23357 96684
99144 73895 66001 93254 58276 78000 61832 98544 26232 82725
75561 10733 16069 70158 64984 22229 12554 85729 87933 71478
66323 17240 55157 56102 35254 39949 99345 60808 38011 90741
53006 00560 55744 81870 96927 85099 77591 80500 75416 42852
77081 62011 35024 68060 58163 27617 16767 65260 93752 80568
44214 48619 39604 99834 47280 67219 06670 41724 00942 34466
19781 24266 90787 53594 46166 98508 06463 61371 66384 04902
92193 41881 90958 16595 24477 86184 61409 12878 29843 84317
03248 17342 88865 72737 66314 65191 04988 02944 79608 14673
76050 39571 96893 71467 18013 75619 05546 29968 14764 26390
39530 07319 10816 98029 38509 89006 21665 09580 86381 10005
57423 42323 08961 09004 10661 99773 92256 25991 82128 90625 (sequence

A018247 in the OEIS)

One automorphic number is found by taking the last *k* digits of this sequence; the second is found by subtracting the first number from 10^{k} + 1.

An *n*-automorphic number is a number *k* such that *nk*^{2} has its last digit(s) equal to *k*. For example, since 3*92^{2} = 25,392 and 25,392 ends with 92, so 92 is 3-automorphic.

Automorphic numbers are radix dependent, and the description above applies to automorphic numbers in base 10. Using other radixes there are different automorphic numbers. 0 and 1 are automorphic numbers in every radix; automorphic numbers other than 0 and 1 only exist when the radix has at least two distinct prime factors.

A single digit number *x* is automorphic in radix *b* > *x* when *b* divides *x*^{2} − *x*. So 6 is automorphic in a radix which is a divisor of 6^{2} − 6 = 30 that is greater than 6; these divisors are 10, 15 and 30.

In any given radix there are 2^{p} sequences of automorphic numbers where *p* is the number of distinct prime factors in the radix. For base 10 this gives 2^{2} = 4 sequences, which are 0,1,5 and 6 for 1 digit or 00, 01, 25, 76 for two digits and so on. A prime power radix (such as 2, 3, 4, 5, 7, 8, 9, 11, 13, 16, 17, 19, 23, 25, 27, 29, 31, 32, etc) can only have 0 and 1 (prepended by one or more zeroes) as automorphic numbers. Base 6 is the first radix with non-trivial automorphic numbers and base 15 the first such odd radix. Base 30 is the first radix with three distinct prime factors and has 8 sequences of automorphic numbers. Here some examples of non-trivial 1, 2 and 4 digit automorphic numbers in some non-primepower radixes (using A−Z to represent digits 10 to 35):

These numbers are the "infinite" solution of *x*^{2} − *x* = 0 in base *b*. In fact, they are the solution of this equation in the ring of *b*-adic numbers. If *b* is a prime power, then the ring is also a field. If it is a field, then the equation can be written as *b*(*b* − 1) = 0, so the only solutions are 0 and 1.

Note that:

the 4-digit numbers that are automorphic in bases 20 and 30, when expressed in decimal, are also automorphic in the last 4 digits.
the 2-digit numbers that are automorphic in bases 20 and 30, when expressed in decimal, are also automorphic in the last 2 digits.