Massive 6174 Kaprekar’s Routine Database & Analysis

Massive 6174 Kaprekar’s Routine Database & Analysis

Kaprekar’s Constant – Blog Posts

Published Database

Here are all of the fixed points for all base-10 numbers of length 1-digit to 79-digits (published 2025, Dec 31, though computed many months previously during 2025):

 

Kaprekar’s Routine

In January 2025, I took on a challenge to extend the knowledge base of computing Kaprekar’s Constant — the famous 6174 constant that is produced by any 4-digit number via Kaprekar’s routine:

  1. sort digits both ways (large to small, small to large)
  2. subtract smaller from larger (keep leading zeroes)
  3. repeat

The result is that every 4-digit number (except trivial repdigit case) ends with 6174.

  • 8531 – 1358 = 7173
  • 7731 – 1377 = 6354
  • 6543 – 3456 = 3087
  • 8730 – 0378 = 8352
  • 8532 – 2358 = 6174

Ignore repdigit numbers that trivially end in all zeroes (E.g. 3333 – 3333 = 0000)

And every 3-digit number ends with 495.

  • 100 – 001 = 099
  • 990 – 099 = 891
  • 981 – 189 = 792
  • 972 – 279 = 693
  • 963 – 369 = 594
  • 954 – 459 = 495

 

The Challenge

Now I wonder…

  • Does this (a single result) happen for every digit length?
  • If not, given finite numbers, they must at least all result in cycles. Do they all result in a single cycle?
  • How many unique cycles are made?
  • What behaviours change as the digit sets get larger?
  • Can I compute them for larger digit lengths than anyone has done before?
  • Can I compute them more efficiently to go well beyond the existing known results?
  • Does it happen for other number bases, other than 10?

To answer these questions, I heavily optimized my software, upgraded it to work for any radix (number base), and ran it on on two Alienware gaming laptops (m15 R1 12-core and m18 R2 32-core) for a couple of months. The original Python source was a trivial implementation running as a single thread, and very slow. Updated to use 32-cores, it still took 56 minutes to produce all base-10 results for digit sets 1-32 length (meaning, it would have been 1.5 days with a single thread). The C# fully optimized version does the same in 4 minutes 3 seconds.

 

First Published Findings

My initial efforts, starting in January 15, 2025:

The main purpose of this post was to take the reader through the discovery process, and not simply shoot straight to the end results of fixed points, loops and cycles, and other interesting facts.

  • It explains the terminology of “fixed point” (number that becomes itself, a loop of length 1) and “cycles” (loops of any length)
  • Through the discovery process, I do lead the reader through the initial discoveries of the smaller length digit sets (2 through 6):
    • 2-digit – single cycle
    • 3-digit – single fixed point = 495
    • 4-digit – single fixed point = 6174 — Kaprekar’s Constant
    • 5-digit – multiple cycles
    • 6-digit – multiple cycles + multiple fixed points
  • It distinguishes between the common phrase that “any 4-digit number takes at most 7 steps to reach 6174” is referring to the cycle start, and not its full cycle repeat (one extra step shows that 6174 becomes 6174 again, which is the proof needed to show you are “finished” without any prior knowledge).

In 5 days, on January 20, 2025, I computed all results (base-10, all fixed points, all cycles) up to 32-digits in length.  This exceeded the highest calculations I have known previously, which was all 31-digit numbers:

 

New Database & Analysis Published

Throughout 2025, I have computed much more.

The computations of Kaprekar’s routine include:

  • All fixed points and all cycles, plus statistical analysis, for the following:
  • All base-2..8 numbers up to 100 digits
  • All base-10 numbers up to 79 digits.
  • All base-11..15 numbers up to 24 digits
  • All base-16 numbers up to 27 digits.
  • All base-17..41 numbers up to 10 digits
  • All base-42..255, up to 5 digits

Have a look at the beginnings of my analysis of the massive database I have produced using Kaprekar’s routine:

The data set includes:

  • Radix = 2 to 255, not just base-10.
  • Digit lengths = 1 to 100 (though not to 100 digits for every base), not just digit length 4 (as in 6174)
  • 3,309 files
  • 129 MB total size

More to come soon.

Enjoy!

 

Resources

 

Jason Doucette Avatar

Leave a Reply