Qm

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

Sign in to join the discussion · reading is open to everyone

💡 Discussion rules

  1. No full solutions here. Hints and approaches only.
  2. Complexity, edge cases and intuition are the point.
  3. Interview experiences are welcome. Respect your NDAs.

Loading discussion…

Learn the concepts

The theory behind this question.

Related questions

The number equal to the sum of the cubes of its digitsThe number that rotates when multipliedThe number that equals the sum of the factorials of its digitsThe four-digit number that reverses when multiplied by fourThe number that describes its own digits
All questions →