In mathematics, a natural number in a given number base is a <math>p</math>-Kaprekar number if the representation of its square in that base can be split into two parts, where the second part has <math>p</math> digits that add up to the original number. For example, in base 10, 45 is a 2-Kaprekar number, because 45<sup>2</sup> = 2025, and 20 + 25 = 45. The numbers are named after D. R. Kaprekar.

Definition and properties

Let <math>n</math> be a natural number. Then the Kaprekar function for base <math>b > 1</math> and power <math>p > 0</math> <math>F_{p, b} : \mathbb{N} \rightarrow \mathbb{N}</math> is defined to be the following:

:<math>F_{p, b}(n) = \alpha + \beta</math>,

where <math>\beta = n^2 \bmod b^p</math> and

:<math>\alpha = \frac{n^2 - \beta}{b^p}</math>

A natural number <math>n</math> is a <math>p</math>-Kaprekar number if it is a fixed point for <math>F_{p, b}</math>, which occurs if <math>F_{p, b}(n) = n</math>. <math>0</math> and <math>1</math> are trivial Kaprekar numbers for all <math>b</math> and <math>p</math>, all other Kaprekar numbers are nontrivial Kaprekar numbers.

The earlier example of 45 satisfies this definition with <math>b = 10</math> and <math>p = 2</math>, because

: <math>\beta = n^2 \bmod b^p = 45^2 \bmod 10^2 = 25</math>

: <math>\alpha = \frac{n^2 - \beta}{b^p} = \frac{45^2 - 25}{10^2} = 20</math>

: <math>F_{2, 10}(45) = \alpha + \beta = 20 + 25 = 45</math>

A natural number <math>n</math> is a sociable Kaprekar number if it is a periodic point for <math>F_{p, b}</math>, where <math>F_{p, b}^k(n) = n</math> for a positive integer <math>k</math> (where <math>F_{p, b}^k</math> is the <math>k</math>th iterate of <math>F_{p, b}</math>), and forms a cycle of period <math>k</math>. A Kaprekar number is a sociable Kaprekar number with <math>k = 1</math>, and a amicable Kaprekar number is a sociable Kaprekar number with <math>k = 2</math>.

The number of iterations <math>i</math> needed for <math>F_{p, b}^{i}(n)</math> to reach a fixed point is the Kaprekar function's persistence of <math>n</math>, and undefined if it never reaches a fixed point.

There are only a finite number of <math>p</math>-Kaprekar numbers and cycles for a given base <math>b</math>, because if <math>n = b^p + m</math>, where <math>m > 0</math> then

: <math>

\begin{align}

n^2 & = (b^p + m)^2 \\

& = b^{2p} + 2mb^p + m^2 \\

& = (b^p + 2m)b^p + m^2 \\

\end{align}

</math>

and <math>\beta = m^2</math>, <math>\alpha = b^p + 2m</math>, and <math>F_{p, b}(n) = b^p + 2m + m^2 = n + (m^2 + m) > n</math>. Only when <math>n \leq b^p</math> do Kaprekar numbers and cycles exist.

If <math>d</math> is any divisor of <math>p</math>, then <math>n</math> is also a <math>p</math>-Kaprekar number for base <math>b^p</math>.

In base <math>b = 2</math>, all even perfect numbers are Kaprekar numbers. More generally, any numbers of the form <math>2^n (2^{n + 1} - 1)</math> or <math>2^n (2^{n + 1} + 1)</math> for natural number <math>n</math> are Kaprekar numbers in base 2.

Set-theoretic definition and unitary divisors

The set <math>K(N)</math> for a given integer <math>N</math> can be defined as the set of integers <math>X</math> for which there exist natural numbers <math>A</math> and <math>B</math> satisfying the Diophantine equation

: <math>X^2 = AN + B</math>, where <math>0 \leq B < N</math>

: <math>X = A + B</math>

An <math>n</math>-Kaprekar number for base <math>b</math> is then one which lies in the set <math>K(b^n)</math>.

It was shown in 2000