Definition:Modified Kaprekar Mapping

Definition
The modified Kaprekar mapping is the arithmetic function $K: \Z_{>0} \to \Z_{>0}$ defined on the positive integers as follows:

Let $n \in \Z_{>0}$ be expressed in some number base $b$ (where $b$ is usually $10$).

Let $n'$ be the positive integer created by:
 * arranging the digits of $n$ into descending order of size

then:
 * exchanging the last two digits.

Let $n''$ be the positive integer created by:
 * arranging the digits of $n$ into ascending order of size

then:
 * exchanging the first two digits.

Then:
 * $\map {K'} n = n' - n''$

making sure to retain any leading zeroes to ensure that $\map K n$ has the same number of digits as $n$.

Also see

 * Definition:Modified Kaprekar Process