Kaprekar's routine takes any non-repdigit number, rearranges its digits into the largest and smallest values, subtracts them, and repeats. For 4-digit inputs the sequence always locks onto 6174 in at most seven steps — the Kaprekar constant. For 3 digits it locks onto 495. Longer widths fall into cycles instead of a single fixed point.
| # | largest | − | smallest | = | next |
|---|
Indian mathematician D. R. Kaprekar noticed in 1949 that this simple operation on 4-digit numbers always terminates at 6174. The proof is finite — there are only 8,991 four-digit inputs (skipping repdigits like 1111) and every one of them reaches 6174 in at most seven iterations. Once there, the routine stays: 7641 − 1467 = 6174. The 3-digit analogue is 495; wider inputs enter cycles of length 2 to 14 instead of a single fixed point. Kaprekar's other famous discoveries — Kaprekar numbers, Harshad numbers, and the self-numbers — remain staples of recreational number theory.