Kaprekar's Constant

Discover the magic of 6174

Enter any four-digit number that has at least two different digits. The application will repeatedly subtract the smallest number formed by its digits from the largest, until it reaches the mysterious Kaprekar's constant: 6174.

How It Works

Kaprekar's routine is a mathematical algorithm discovered by the Indian mathematician D. R. Kaprekar in 1949. For any four-digit number (where not all digits are the same), this process will always lead to the number 6174, which is known as Kaprekar's constant.

The process is as follows:

  1. Take any four-digit number. (The only condition is that you cannot have all four digits be the same, like 1111 or 2222).
  2. Arrange the digits in descending order to get the largest number possible.
  3. Arrange the digits in ascending order to get the smallest number possible. (If you have leading zeros, like from the number 0123, they still count).
  4. Subtract the smaller number from the larger number.
  5. Repeat the process with the result of the subtraction.

Amazingly, within a maximum of 7 steps, you will always arrive at the number 6174. Once you reach 6174, the process becomes a loop: 7641 - 1467 = 6174.