Kaprekar's constant, 6174
Take any four-digit number that has at least two different digits (leading zeros allowed, so 0031 counts). Arrange its digits in descending order to make the biggest possible number, and in ascending order to make the smallest. Subtract the smaller from the larger. Repeat with the result.
For example, from 3524: 5432 minus 2345 = 3087; then 8730 minus 0378 = 8352; then 8532 minus 2358 = 6174; then 7641 minus 1467 = 6174.
What number does every starting number reach, and what happens once you get there? How many steps can it take at most?
Show a hint
Try a few starting numbers by hand and watch what happens after you first hit 6174.
Your answer
Solving needs a free account
Answers, streaks and solutions unlock when you are signed in. Reading the question and the hint stays free.
Discussion
💡 Discussion rules
- No full solutions here. Hints and approaches only.
- Complexity, edge cases and intuition are the point.
- Interview experiences are welcome. Respect your NDAs.
Loading discussion…
Learn the concepts
The theory behind this question.