<?xml version="1.0" encoding="UTF-8"?>

<record version="2" id="8386">
 <title>Kaprekar constant</title>
 <name>KaprekarConstant</name>
 <created>2006-09-20 18:37:13</created>
 <modified>2006-09-20 18:42:13</modified>
 <type>Definition</type>
 <creator id="13766" name="PrimeFan"/>
 <author id="12020" name="Lando47"/>
 <classification>
	<category scheme="msc" code="11A63"/>
 </classification>
 <defines>
	<concept>Kaprekar routine</concept>
 </defines>
 <synonyms>
	<synonym concept="Kaprekar constant" alias="Kaprekar's constant"/>
 </synonyms>
 <preamble>% this is the default PlanetMath preamble.  as your knowledge
% of TeX increases, you will probably want to edit this, but
% it should be fine as is for beginners.

% almost certainly you want these
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsfonts}

% used for TeXing text within eps files
%\usepackage{psfrag}
% need this for including graphics (\includegraphics)
%\usepackage{graphicx}
% for neatly defining theorems and propositions
%\usepackage{amsthm}
% making logically defined graphics
%\usepackage{xypic}

% there are many more packages, add them here as you need them

% define commands here
</preamble>
 <content>The {\em Kaprekar constant} $K_k$ in a given base $b$ is a $k$-digit number $K$ such that subjecting any other $k$-digit number $n$ (except the repunit $R_k$ and numbers with $k - 1$ repeated digits) to the following process:

1. Arrange the digits of $n$ in ascending order, forming the $k$-digit number $a$, and then in descending order, forming the $k$-digit number $b$.

2. If $a &gt; b$, calculate $a - b = c$; otherwise $b - a = c$.

3. Goto step 1 using $c$ instead of $n$.

eventually gives $K$. (This process is sometimes called the {\em Kaprekar routine}).

For $b = 10$, the Kaprekar constant for $k = 4$ is 6174. Using $n = 1729$, we find that 9721 - 1279 gives 8442. Then 8442 - 2448 = 5994. Then 9954 - 4599 gives 5355. Then 5553 - 3555 gives 1998. Then 9981 - 1899 gives 8082. Then 8820 - 288 gives 8532. Then 8532 - 2538 finally gives 6174. (Some numbers take longer than others). $K_2$ and $K_7$ don't exist for $b = 10$.</content>
</record>
