Playground · Kaprekar
Kaprekar’s routine.
Pick almost any four-digit number and it ends up at 6174. I didn’t believe it either.
This started with a video about 6174 that I couldn’t stop thinking about. The claim sounded too simple. Take almost any four-digit number, follow one rule, and you always land on the same answer. I read a few articles, tried some calculators and watched more videos until it clicked. Then I built my own to see it happen.
It’s a playground experiment, not a finished project, so it might change as I tinker with it.
The rule
Pick a four-digit number with at least two different digits. Sort the digits from high to low, then from low to high. Take the smaller number away from the bigger one. Do it again with the answer. Within seven steps you’ll hit 6174, known as Kaprekar’s constant. After that it just repeats.
The maths
Zeros count. 3087 sorts to 8730 and 0378, so the zero stays at the front. The only numbers that don’t work are ones where all four digits match, like 1111 or 7777. They go straight to zero.