Pick a number with three or four digits, using at least two different digits. Sort the digits one way, then the other. Subtract the smaller from the larger. Do it again with the answer.
At three digits you always reach 495. At four digits you always reach 6174. This is the routine the Indian schoolteacher D. R. Kaprekar discovered in 1949. It still works.
This is the classical Kaprekar routine: sort the digits descending, sort them ascending, subtract. Repeat. At three digits the routine always reaches 495 (within six steps). At four digits it always reaches 6174 (within seven steps). The two numbers are sometimes called Kaprekar's constants.
The routine is famous because of how clean it is: one simple rule, one number every input ends up at, and a short proof you can almost do in your head. Try it with five-digit numbers, though, and the routine stops working: you bounce around in a small loop forever instead of reaching a fixed number. For a long time, that was the end of the story.
The companion 60714 calculator picks up where this one leaves off. It iterates a slightly different rule that does have a five-digit fixed point. Unlike Kaprekar's original, the new rule keeps reaching a fixed point at six digits, seven digits, and every length above.
Full paper, the proof, and reproducibility scripts: github.com/clayelmore/Kaprekar-60714