# What is the logic behind Kaprekar's Constant?

Kaprekar's constant, or 6174, is a constant that arises when we take a 4-digit integer, form the largest and smallest numbers from its digits, and then subtract these two numbers. Continuing with this process of forming and subtracting, we will always arrive at the number 6174. 6174 is known as Kaprekar's constant after the Indian mathematician D. R. Kaprekar. The above process, known as Kaprekar's routine, will always reach its fixed point, 6174, in at most 8 iterations. Once 6174 is reached, the process will continue yielding 7641 – 1467 = 6174.

What exactly is the logic behind this process? Is there any intuitive proof?

• Probably not; the outcome could have been lots of things, but it seems that it just happened to be this outcome. Commented Jun 26, 2021 at 5:58
• This may help: math.stackexchange.com/questions/1325033/… Commented Jun 26, 2021 at 7:40

The way I see it: imagine all the possible procedures you could do on all the possible intervals of numbers. You're looking for one reasonably simple procedure on an easily described interval which has the property that it has a unique fixed point. Loads of procedures have fixed points (e.g. Brouwer's theorem; $$1-1/e \approx 63\%$$ of all permutations are not derangements and therefore have at least one fixed point; etc.). Some of them will have unique fixed points. Finding a particularly nice procedure with a unique fixed point is probably going to be challenging, but when crowd-sourced it's not too surprising that somebody found one.
The proof of Kaprekar's constant uses that idea. After one application of the function, you have a lot fewer cases to check. Step one is to show that after one application of the function, you have a multiple of $$9$$. So the image set is $$1/10$$ the size of the original set. Step two is to realize that it's sufficient to check only numbers which have decreasing digits. There are only $$79$$ four-digit multiples of $$9$$ with decreasing digits.
I think the reason is that, in base 10, the map $$f:X \rightarrow X$$ defined by Kaprekar is onto and contractive, so by the contraction mapping theorem, there is a unique fixed point. In other bases the map is not contractive but is onto, so by the Brouwer Fixed Point Theorem, it must have a fixed point (possibly more than one). The Wikipedia page Kaprekar's routine gives exact results for many bases.