Run Kaprekar's routine to the fixed point 6174 or 495, and check Kaprekar numbers.
Kaprekar's routine takes a number, arranges its digits from highest to lowest and from
lowest to highest, then subtracts the smaller arrangement from the larger one. Repeating this on a
four-digit number with at least two different digits always reaches 6174, known as
Kaprekar's constant. Three-digit numbers settle on 495 instead.
Example: 3524 → 5432 minus 2345 = 3087 → 8730 minus 0378 = 8352 → 8532 minus 2358 = 6174.
Numbers whose digits are all the same, like 1111 or 3333, collapse straight to 0 and have no constant.
Kaprekar's routine
Digit width
Kaprekar number checker
A Kaprekar number is a number n whose square can be split into a left part and a right
part that add up to n. For example 45, because 45² = 2025 and 20 + 25 = 45.