# Kaprekar number

Not to be confused with Kaprekar's constant.

In mathematics, a Kaprekar number for a given base is a non-negative integer, the representation of whose square in that base can be split into two parts that add up to the original number again. For instance, 45 is a Kaprekar number, because 45² = 2025 and 20+25 = 45. The Kaprekar numbers are named after D. R. Kaprekar.

## Definition

Let X be a non-negative integer. X is a Kaprekar number for base b if there exist non-negative integers n, A, and positive number B satisfying:

X² = Abn + B, where 0 < B < bn
X = A + B

Note that X is also a Kaprekar number for base bn, for this specific choice of n. More narrowly, we can define the set K(N) for a given integer N as the set of integers X for which[1]

X² = AN + B, where 0 < B < N
X = A + B

Each Kaprekar number X for base b is then counted in one of the sets K(b), K(b²), K(b³),….

## Examples

297 is a Kaprekar number for base 10, because 297² = 88209, which can be split into 88 and 209, and 88 + 209 = 297. By convention, the second part may start with the digit 0, but must be positive. For example, 999 is a Kaprekar number for base 10, because 999² = 998001, which can be split into 998 and 001, and 998 + 001 = 999. But 100 is not; although 100² = 10000 and 100 + 00 = 100, the second part here is not positive.

The first few Kaprekar numbers in base 10 are:

1, 9, 45, 55, 99, 297, 703, 999, 2223, 2728, 4879, 4950, 5050, 5292, 7272, 7777, 9999, 17344, 22222, 38962, 77778, 82656, 95121, 99999, 142857, 148149, 181819, 187110, 208495, 318682, 329967, 351352, 356643, 390313, 461539, 466830, 499500, 500500, 533170, ... (sequence A006886 in OEIS)

In particular, 9, 99, 999… are all Kaprekar numbers. More generally, for any base b, there exist infinitely many Kaprekar numbers, including all numbers of the form bn - 1.

## Properties

• It was shown in 2000[1] that the Kaprekar numbers for base b are in bijection with the unitary divisors of bn − 1, in the following sense. Let Inv(a,b) denote the multiplicative inverse of a modulo b, namely the least positive integer m such that $am \equiv 1 \pmod b$. Then, a number X is in the set K(N) (defined above) if and only if X = d Inv(d, (N-1)/d) for some unitary divisor d of N-1. In particular,