(Text as at 04/06/2020 23:48:29)

Note Citations |
---|

- A friend alerted me to an interesting mathematical phenomenon, described here: Guardian: 6174 (Kaprekar's Constant), though there are discussions on Wikipedia: Kaprekar's routine.
- Basically, it’s a fascinating fact that if you take any 4-digit number, sort its digits ascending and descending to give two further 4-digit numbers, take the smaller from the larger, and repeat the process until the number repeats in consecutive calculations, then you always end up with the number 6174 in 7 or fewer iterations. 6,174 is Kaprekar’s number, after the Indian mathematician who discovered the process (Wikipedia: 6174 - Kaprekar's Number).
- You have to avoid degenerate numbers like “1111”, which transform onto 0 immediately.
- I wrote a program in Access VBA (Kaprekar_Main) to check this out, and find out how many iterations each 4-digit number took, and store the results in a database. I made the process generic so that it could run for numbers of different lengths, but put a throttle on the number of iterations (a parameter set to 20) as for 5-digit and longer numbers, there are in general no universal solutions, though there are usually “Fixed points of the Kaprekar mapping” that map onto themselves, but in general most numbers cycle round without encountering one of these.
- When I ran it for 3-digit numbers they all (other than the degenerates) converged to 495.
- Running for 5-digit and 7-digit numbers produced no fixed points.
- Running for 6-digit numbers produced two fixed points (631764 and 549945).
- Finally, running for 8-digit numbers also produced two fixed points (63317664 and 97508421). The run took 5 hours as I was trying to determine the number of numbers that converged within a 20-iteration limit. To find the fixed points I’d only need one iteration, but as the process is escalating exponentially, I wouldn’t get much further, so there seemed no point.
- In any case, the spade-work has been done elsewhere, as is revealed by a page on OEIS: The On-Line Encyclopedia of Integer Sequences, namely OEIS: Fixed Points of the Kaprekar Mapping, which contains a link to a simple list: OEIS: Table of Kaprekar Numbers, which confirms that I’d got the fixed points up to 8 digits all present and correct.
- For the record, the table of number-length, fixed points, and count of numbers converging within n iterations, is given below. It was interesting that all the 6 and 8-digit numbers that converged did so in 4 or fewer iterations.
- I’ve not yet followed up the various OEIS links, and probably won’t.

Length | Final Number | 1 | 2 | 3 | 4 | 5 | 6 | 7 | Total |
---|---|---|---|---|---|---|---|---|---|

3 | 0 | 9 | 9 | ||||||

3 | 495 | 150 | 144 | 270 | 222 | 150 | 54 | 990 | |

4 | 0 | 9 | 9 | ||||||

4 | 6174 | 384 | 576 | 2,400 | 1,272 | 1,518 | 1,656 | 2,184 | 9,990 |

5 | 0 | 9 | 9 | ||||||

6 | 0 | 9 | 9 | ||||||

6 | 549945 | 1,950 | 1,950 | ||||||

6 | 631764 | 8,160 | 12,360 | 39,120 | 2,880 | 62,520 | |||

7 | 0 | 9 | 9 | ||||||

8 | 0 | 9 | 9 | ||||||

8 | 63317664 | 69,440 | 198,240 | 308,336 | 23,520 | 599,536 | |||

8 | 97508421 | 604,800 | 1,505,280 | 260,960 | 2,371,040 |

Note last updated | Reference for this Topic | Parent Topic |
---|---|---|

04/06/2020 23:48:29 | 1304 (Kaprekar's Constant) | None |

Theo Todman's Blog |

To access information, click on one of the links in the table above.

- Blue: Text by me; © Theo Todman, 2023

© Theo Todman, June 2007 - Sept 2023. | Please address any comments on this page to theo@theotodman.com. | File output: Website Maintenance Dashboard |

Return to Top of this Page | Return to Theo Todman's Philosophy Page | Return to Theo Todman's Home Page |