The subtraction rule compresses many numbers into one path

This repeating operation is known as Kaprekar’s routine, named after mathematician D. R. Kaprekar. Its surprising feature is not that subtraction makes numbers smaller every time—it does not—but that sorting the digits first sharply limits what can happen next.

For digits arranged as a ≥ b ≥ c ≥ d, the descending number minus the ascending one is always 999(a − d) + 90(b − c). That formula shows why the result has a restricted shape: it is built from just the gaps between the outer and inner digits, rather than from all four digits independently.

For example, start with 3524:

  • 5432 − 2345 = 3087
  • 8730 − 0378 = 8352
  • 8532 − 2358 = 6174

A leading zero, as in 0378, still counts as part of the four-digit arrangement.

Why 6174 becomes a stopping point

Once the routine reaches 6174, sorting gives 7641 and 1467. Their difference is 6174, so the number repeats forever. It is a fixed point: applying the rule leaves it unchanged.

The broader reason convergence is possible is that there are only 10,000 four-digit strings, and each one has exactly one next result. Repeating the rule must eventually revisit a number, creating a loop. For four-digit numbers with at least two different digits, that loop leads to 6174; numbers with all four digits the same instead produce 0000.

The sorting step is what makes this more than ordinary repeated subtraction. It funnels a huge variety of starting arrangements into a much smaller set of possible results, and those results funnel into the same loop. 6174 is memorable because a simple digit rearrangement repeatedly erases the differences between most starting numbers.