KAPREKAR.FUN

Sign up for Starlink and get €45

Fast, reliable internet at home and on the go. Sign up through our link and get €45 in cash or Starlink service credit. Terms apply.
Get €45
← All articles

Beyond four digits

Kaprekar’s routine with 2, 5, 6 and 7 digits

4 min read · Updated 19 September 2026

Four digits give 6174 and three digits give 495. It is natural to assume every length has its own constant, but that is not what happens. We ran the routine on every input for two to seven digits. Only three and four digits have one single destination; the other lengths split into loops and competing fixed points.

How we counted

For each width we applied the routine to every zero-padded input, for example 00000 to 99999 for five digits, skipped the repdigits that collapse to zero, and followed each path until a state repeated. Because the number of states is finite, every path must eventually enter a fixed point or a cycle. The tables below list every destination and how many inputs reach it.

The same method powers the cycle explorer on this site.

Two digits: a five-step loop

With two digits there is no fixed point. Every valid input enters the same loop:

09 → 81 → 63 → 27 → 45 → 09

The first difference is 9 × (a − b), so every value is a multiple of 9, just as in the four-digit case. All 90 valid inputs end in this five-number cycle.

Three and four digits: one destination each

DigitsDestinationValid inputsMaximum steps
34959906
461749,9907

These are the only two widths with a single universal attractor. The reason is explained in why every number reaches 6174.

Five digits: no fixed point, three cycles

Five digits produce no fixed point at all. Instead every input falls into one of three loops:

CycleLengthInputs reaching it
53955 → 59994 → 5395523,190
61974 → 82962 → 75933 → 63954 → 61974448,480
62964 → 71973 → 83952 → 74943 → 62964448,320

The two four-number loops share the input space almost equally, while the short two-number loop catches only about 3%.

Six digits: two constants and a long loop

Six digits bring back fixed points, but two of them compete, and most inputs avoid both:

DestinationTypeInputs reaching it
549945fixed point1,950
631764fixed point62,520
840852 → 860832 → 862632 → 642654 → 420876 → 851742 → 750843seven-number cycle935,520

Check the fixed points yourself: 995544 − 445599 = 549945 and 766431 − 134667 = 631764. Notice that 631764 contains the digits of 6174 plus 3 and 6. Around 94% of six-digit inputs end in the seven-number loop.

Seven digits: one eight-number loop

For seven digits we found a single destination again, but it is a cycle rather than a constant:

7509843 → 9529641 → 8719722 → 8649432 → 7519743 → 8429652 → 7619733 → 8439552 → 7509843

Every non-repdigit seven-digit input eventually circles through these eight numbers.

Checking a cycle by hand

You do not need a computer to confirm a cycle. Take the five-digit two-number loop:

53955 → sorted 95553 − 35559 = 59994

59994 → sorted 99954 − 45999 = 53955

Two subtractions bring you back to the start, so the pair repeats forever. The same test works for the longer loops: apply the routine to each member and confirm that it produces the next one. For fixed points one subtraction is enough, as with 7641 − 1467 = 6174.

Proving that a list of destinations is complete is harder, because every input has to be followed. With five digits that means 99,990 paths. In practice it helps that sorting makes many inputs identical: only the multiset of digits matters, so there are just 2,002 genuinely different five-digit starting points, including the repdigits.

What this tells us

Kaprekar’s routine is a deterministic map on a finite set, so it must end in a fixed point or a cycle. Which one depends on the arithmetic of the chosen width. Three and four digits happen to funnel everything into a single fixed point; other widths do not. That makes 495 and 6174 genuinely special rather than members of a guaranteed family.

A similar finite-state argument explains why happy numbers always end at 1 or in one loop. By contrast, the Collatz conjecture works on unbounded numbers, and no such argument is available.

KAPREKAR.FUN

A playground for curious numbers.

info@kaprekar.fun