Kaprekar's Routine Calculator

See how many steps a number takes to reach 6174.

How it is calculated

Kaprekar's routine works on a four-digit number. Pad it with leading zeros to four digits, sort the digits from largest to smallest to get D, from smallest to largest to get A, and compute D - A. The difference is padded to four digits again and the step is repeated until the number 6174 appears. The tool reports how many subtractions were needed.

Numbers from 0 to 9999 are accepted, so 12 is treated as 0012. Numbers whose four digits are all identical (0000, 1111 ... 9999) have no result, since they collapse to 0 and never reach 6174. Starting from 6174 itself needs 0 steps.

Worked example

Start with 3524. Step 1: 5432 - 2345 = 3087. Step 2: 8730 - 0378 = 8352. Step 3: 8532 - 2358 = 6174. The number 6174 is reached, so the answer is 3 steps, ending at the constant 6174.

Try this example →

Common mistakes

  • Dropping the leading zero: 0378 must stay four digits, and leaving it as 378 changes how the digits are sorted in later steps.
  • Trying numbers with four identical digits such as 1111; they give 0 after one step and the tool returns nothing.
  • Entering a number with more than four digits or a negative number, which is outside the supported range.
  • Expecting the same step count for numbers that look similar: 3524 takes 3 steps but 2111 takes 5.
  • Applying the routine to 3-digit or 5-digit numbers and expecting 6174; those cases lead to other constants or cycles, and this tool only handles four digits.

About this calculator

This calculator runs Kaprekar's routine on a 4-digit number: arrange its digits in descending and ascending order, subtract the smaller from the larger, and repeat — a process that reaches the constant 6174 (Kaprekar's constant) within at most 7 iterations for any 4-digit number with at least two different digits.

Recreational mathematicians and students use it to explore this quirky self-referential property discovered by D. R. Kaprekar in 1949, watching how quickly any starting number converges.

Was this helpful?

You can pick up to 3 reactions.

Comments

  • Be the first to comment.

Popular calculators

All Calculators