Kaprekar number


In mathematics, a natural number in a given number base is a -Kaprekar number if the representation of its square in that base can be split into two parts, where the second part has digits, that add up to the original number. The numbers are named after D. R. Kaprekar.

Definition and properties

Let be a natural number. We define the Kaprekar function for base and power to be the following:
where and
A natural number is a -Kaprekar number if it is a fixed point for, which occurs if. and are trivial Kaprekar numbers for all and, all other Kaprekar numbers are nontrivial Kaprekar numbers.
For example, in base 10, 45 is a 2-Kaprekar number, because
A natural number is a sociable Kaprekar number if it is a periodic point for, where for a positive integer, and forms a cycle of period. A Kaprekar number is a sociable Kaprekar number with, and a amicable Kaprekar number is a sociable Kaprekar number with.
The number of iterations needed for to reach a fixed point is the Kaprekar function's persistence of, and undefined if it never reaches a fixed point.
There are only a finite number of -Kaprekar numbers and cycles for a given base, because if, where then
and,, and. Only when do Kaprekar numbers and cycles exist.
If is any divisor of, then is also a -Kaprekar number for base.
In base, all even perfect numbers are Kaprekar numbers. More generally, any numbers of the form or for natural number are Kaprekar numbers in base 2.

Set-theoric definition and unitary divisors

We can define the set for a given integer as the set of integers for which there exist natural numbers and satisfying the Diophantine equation
An -Kaprekar number for base is then one which lies in the set.
It was shown in 2000 that there is a bijection between the unitary divisors of and the set defined above. Let denote the multiplicative inverse of modulo, namely the least positive integer such that, and for each unitary divisor of let and. Then the function is a bijection from the set of unitary divisors of onto the set. In particular, a number is in the set if and only if for some unitary divisor of.
The numbers in occur in complementary pairs, and. If is a unitary divisor of then so is, and if then.

Kaprekar numbers for F_{p, b}

''b'' = 4''k'' + 3 and ''p'' = 2''n'' + 1

Let and be natural numbers, the number base, and. Then:
Let,, and be natural numbers, the number base, and the power. Then:
Let,, and be natural numbers, the number base, and the power. Then:
Let,, and be natural numbers, the number base, and the power. Then:
Let,, and be natural numbers, the number base, and the power. Then:
All numbers are in base.
BasePowerNontrivial Kaprekar numbers,Cycles
2110
312, 10
413, 10
514, 5, 10
615, 6, 10
713, 4, 6, 10
817, 102 → 4 → 2
918, 10
1019, 10
1115, 6, A, 10
121B, 10
1314, 9, C, 10
141D, 10
1517, 8, E, 10
2 → 4 → 2
9 → B → 9
1616, A, F, 10
2211
3222, 100
4212, 22, 33, 100
5214, 31, 44, 100
6223, 33, 55, 100
15 → 24 → 15
41 → 50 → 41
7222, 45, 66, 100
8234, 44, 77, 100
4 → 20 → 4
11 → 22 → 11
45 → 56 → 45
23111, 100010 → 100 → 10
33111, 112, 222, 100010 → 100 → 10
24110, 1010, 1111, 10000
34121, 2102, 2222, 10000
2511111, 100000
10 → 100 → 10000 → 1000 → 10
111 → 10010 → 1110 → 1010 → 111
3511111, 22222, 10000010 → 100 → 10000 → 1000 → 10
2611100, 100100, 111111, 1000000
100 → 10000 → 100
1001 → 10010 → 1001
100101 → 101110 → 100101
3610220, 20021, 101010, 121220, 202202, 212010, 222222, 1000000
100 → 10000 → 100
122012 → 201212 → 122012
271111111, 10000000
10 → 100 → 10000 → 10
1000 → 1000000 → 100000 → 1000
100110 → 101111 → 110010 → 1010111 → 1001100 → 111101 → 100110
371111111, 1111112, 2222222, 10000000
10 → 100 → 10000 → 10
1000 → 1000000 → 100000 → 1000
1111121 → 1111211 → 1121111 → 1111121
281010101, 1111000, 10001000, 10101011, 11001101, 11111111, 100000000
382012021, 10121020, 12101210, 21121001, 20210202, 22222222, 100000000
2910010011, 101101101, 111111111, 1000000000
10 → 100 → 10000 → 100000000 → 10000000 → 100000 → 10
1000 → 1000000 → 1000
10011010 → 11010010 → 10011010

Extension to negative integers

Kaprekar numbers can be extended to the negative integers by use of a signed-digit representation to represent each integer.

Programming exercise

The example below implements the Kaprekar function described in the definition above to search for Kaprekar numbers and cycles in Python.

def kaprekarf -> int:
beta = pow % pow
alpha = // pow
y = alpha + beta
return y
def kaprekarf_cycle -> List:
seen =
while x < pow and x not in seen:
seen.append
x = kaprekarf
if x > pow:
return
cycle =
while x not in cycle:
cycle.append
x = kaprekarf
return cycle