Number Curiosity

Kaprekar's Constant

Pick almost any 4-digit number. Reorder its digits high-to-low, then low-to-high, and subtract. Repeat. You always end up here.

6174
Every non-repeating 4-digit
number reaches it in 7 steps or fewer.

What's going on here?

In 1949, Indian mathematician D. R. Kaprekar discovered a strange property of the number 6174, now known as Kaprekar's routine. It works like this:

  1. Take any 4-digit number that isn't made of the same digit repeated (so not 1111, 2222, etc.). Leading zeros are allowed — 0026 counts as a 4-digit number.
  2. Arrange its digits into the largest possible number (descending order) and the smallest possible number (ascending order).
  3. Subtract the smaller from the larger.
  4. Take that result and repeat the process.

No matter which starting number you pick, you'll land on 6174 within seven repetitions — and once you're there, the routine just keeps producing 6174 forever (7641 − 1467 = 6174). Numbers made of a single repeated digit (1111, 2222…) are the only exception: descending and ascending give the same number, so the subtraction collapses straight to 0000 instead.

I built a spreadsheet that ran every possible 4-digit combination (excluding the repeated-digit ones) through the reorder / reverse / subtract cycle, feeding each result back in until it hit 6174. Kaprekar was, unsurprisingly, correct — every single one got there. The fastest was numbers like 0026, which reach 6174 in a single step. The slowest, needing the full seven iterations, included numbers like 9985.

Watch the original explanation

Presented by Roger Bowley (University of Nottingham) for Numberphile, created by Brady Haran — youtube.com/@numberphile. This is where I first came across Kaprekar's routine, and it's a much better watch than my spreadsheet. Full credit to the original.

Try it yourself

Enter any 4-digit number and watch it walk to 6174.

Please enter exactly 4 digits (0–9 only).
All four digits are the same, so the descending and ascending arrangements are identical — the subtraction gives 0000 straight away rather than reaching 6174. Try a number with at least two different digits.

Explore all 9,990 numbers

Every 4-digit number that isn't a repeated digit, grouped by how many iterations it takes to reach 6174. The dataset (~185KB) loads only when you ask for it.

Loading…

Click a bar to filter by iteration count.

↻  Clear filter (show all 9,990)
NumberIterations

References & further reading

  • Wikipedia — 6174 (number) Overview of the constant, its properties, and the repdigit/leading-zero edge cases.
  • Wikipedia — Kaprekar's routine The general algorithm, including its 3-digit (495) and other-base variants.
  • OEIS A099009 On-Line Encyclopedia of Integer Sequences — the family of Kaprekar fixed points (495, 6174, 549945, 631764…).
  • Wolfram MathWorld — Kaprekar Routine A more technical write-up, including the 3-digit and generalised n-digit cases.
  • Kaprekar, D. R. (1955). “An Interesting Property of the Number 6174.” Scripta Mathematica, 15, 244–245. Kaprekar's original paper describing the discovery.