6174: The Most Useless Fascinating Number I Have Come Across
Published on September 1, 2024 by Hemanth
--
Ever since I wrote my last essay on 142857 — The Cyclic Number, I have been scanning the numbers-landscape to find other interesting numbers that I have been missing out on. This is how I came across 6174, a number that appears most ordinary on the surface. But just like the cyclic number, the deeper I tried to understand 6174, the more interesting and bizarre the mathematics got.
I will start this essay by explaining what makes 6174 (the 4-digit number) so special. Following this, in a quest to understand why this number appears repeatedly in places we do not quite expect, I will explore similar mathematical behaviour in lower dimensions such as with 2-digit numbers and 3-digit numbers.
The lower dimensional behaviour is easier to grasp and offers a nice basis to start understanding what could be going on with 6174, which is what I will be tackling finally. If you are intrigued about this number or numbers in general, you might enjoy reading this essay. Let us begin.
The Recurring Fixed Point
The mathematical phenomenon that I am about to share with you was originally presented by an Indian mathematician named D.R. Kaprekar in 1959. He proposed an algorithm/function where we consider any 4-digit number, except numbers that feature the same digits. For example, 5793 would be allowed while 0000 or 9999 would not be allowed (you will realise why shortly).
Since I just mentioned 5793, why don’t we consider that number for the first illustration? Kaprekar’s algorithm/function involves the following three steps:
Step 1: Create a new number ‘A’ by rearranging the digits in their descending order. For 5793, A = 9753.
Step 2: Create a new number ‘B’ by rearranging the digits in their ascending order. For 5793, B = 3579.
Step 3: Find the difference between A and B. For 5793, A – B = 6174.
Please make a note of this algorithm as we will be applying it on multiple occasions throughout this essay. As you can see, for 5793, the algorithm results in 6174. This could just be a fluke, right?
Why don’t we test that hypothesis out? Let us consider 6859 and apply Kaprekar’s algorithm once more:
Step 1: For 6859, A = 9865
Step 2: For 6859, B = 5689
Step 3: For 6859, A – B = 4176
Were you secretly expecting 6174? If so, do not fret yet. Let us apply Kaprekar’s algorithm recursively to 4176 as well:
Step 1: For 4176, A = 7641
Step 2: For 4176, B = 1467
Step 3: For 4176, A- B = 6174
This time, we indeed arrive at 6174! The first time around (for 5793), we got 6174 immediately when we applied Kaprekar’s algorithm. The second time around (for 6859), we had to apply Kaprekar’s algorithm recursively to the first number that resulted (4176) to arrive at 6174.
In this case, 4176 is called a Kaprekar number and 6174 is called Kaprekar’s constant. It turns out that when we apply Kaprekar’s algorithm to any 4-digit number (that doesn’t feature the same 4 digits) recursively, the number of steps to reach 6174 varies from 1 to 7. In other words, it might take a while, but we would inevitably end up with 6174.
At this point, if you are the curious type, you might be wondering what happens when we apply Kaprekar’s algorithm to 6174. Why don’t we find out?
Step 1: For 6174, A = 7641
Step 2: For 6174, B = 1467
Step 3: For 6174, A – B = 6174
How fascinating! We end up with 6174 once again. In other words, regardless of the path we take, we will end up with a fixed point at 6174. This is why 6174 is called Kaprekar’s constant, whereas the intermediate numbers are called Kaprekar numbers. The original number we started with (like 5793) is called a seed number.
But why does this pattern occur? To begin understanding the underlying reasons, I would like to take you through the 2-digit and the 3-digit case. The details we are about to uncover are both revealing and surprising. Let us start with the 2-digit case.
The Limit Cycle
To begin, let us onsider the number 90 and apply Kaprekar’s algorithm to it:
Step 1: For 90, A = 90
Step 2: For 90, B = 09
Step 3: For 90, A – B = 81
Beyond this point, we will be applying Kaprekar’s algorithm recursively multiple times. So, to be more concise, I will just represent the results (Kaprekar numbers) like so: Seed number → Kaprekar number → Kaprekar number → Kaprekar number …
The sequence of Kaprekar numbers that follows the original number is called a Kaprekar sequence. For the number 90, the Kaprekar sequence looks like so:
90 → 81 → 63 → 27 → 45 → 09 → 81 → …
Do you notice anything particularly of interest here? Take a moment if you need to. For starters, ALL of these numbers are multiples of 9. Secondly, notice how at step 1, we arrived at 81, and at step 6 (I am considering 90 as step 0 here), we arrived at 81 again. If we continued to apply Kaprekar’s algorithm beyond this point, the Kaprekar sequence from 81 through 09 would just repeat infinitely.
In the context of number theory/sequences, such a cycle is called a Limit Cycle.
It could be a fluke that we ended up with multiples of 9 since we started with 90. So, let us start with another unrelated seed number: 16. The Kaprekar sequence for 16 is as follows:
16 → 45 → 09 → 81 → 63 → 27 → 45 → …
Isn’t that fascinating? We once again end up with a sequence involving multiples of 9 that keeps repeating itself every 6 steps.
Our little discovery that the Kaprekar numbers are multiples of 9 is useful in and of itself. But we could go one step further and prove that the Kaprekar numbers for 2-digits MUST be multiples of 9.
Let ‘a’ and ‘b’ be the two digits of the original number such that a > b. Consequently, from the first step of Kaprekar’s algorithm, we would get A = ab. From the second step, we would get B = ba. Finally, using the third step, we could write the formula for any Kaprekar number as follows:
Kaprekar number (K) = ab – ba
In the first number (from the left), ‘a’ represents the 10’s place (in the decimal system) and ‘b’ represents 1’s place (in the decimal system). For the second number, it is the other way around. As a result, we could represent the same formula as follows:
The 2-digit Kaprekar number formula — Math illustrated by the author
On the one hand, this relation proves that all Kaprekar numbers in the 2-digit case MUST be multiples of 9. On the other hand, this relation gives us a way to predict the next Kaprekar number given one. Using this, we could establish a table of all possible Kaprekar sequences. This would be cumbersome, but it would still be better than shooting blind with probabilities (the entropy is significantly reduced with a finite table).
When we started investigating this behaviour, we knew almost nothing. But now, we have come quite some way. What more can we understand/learn? Let us proceed with the 3-digit case and find out.
The Limit Cycle Vanishes
Since we have already done the grunt work of laying out the basics in the previous cases, I can afford to be a little quicker with the 3-digit case. Let me start by laying out the Kaprekar sequence for the 3-digit seed number 741:
741 → 594 → 495 → 495
Wait, what? Our limit cycle from the 2-digit case has vanished, giving rise to Kaprekar’s constant for the 3-digit case (495). Just to be thorough, let me present to you the Kaprekar sequences for two more seed numbers as follows (142 and 480):
142 → 297 → 693 → 594 → 495 → 495
480 → 792 → 495 → 495
Do you notice anything particularly of interest here? Again, take a moment if you need to. First of all, all of the Kaprekar numbers feature 9 as their middle digit. Secondly, the sum of the first and last digits is always 9. Consequently, the sum of all the digits for 3-digit Kaprekar numbers is always 18. Why is this?
We could use the same mathematical procedure we used for the 2-digit case to understand why. Let the seed number be represented by abc, where all three digits are not equal and a ≥ b ≥ c. The, the formula for Kaprekar number is as follows:
K = abc – cba
For the first number (from the left), ‘a’ takes the 100’s place, ‘b’ takes the 10’s place, and ‘c’ takes the 1’s place. For cba (the second number), it is the other way around. Consequently, we could rewrite the formula as follows:
The 3-digit Kaprekar number formula — Math illustrated by the author
This formula tells us two things:
1. All 3-digit Kaprekar numbers are multiples of 99 (and 9).
2. Any 3-digit Kaprekar number could be computed using JUST the first and last digits of the seed/Kaprekar number.
You could also see the elimination of the middle digit (9) as noise/entropy reduction. With this, we have a way of predicting the behaviour of Kaprekar’s algorithm/function for the 3-digit case as well. At this point, we are finally prepared to tackle the 4-digit case (6174).
The Equivalence Class
Just like we defined the seed number for the 2-digit case and the 3-digit case, let us say that the seed number for the 4-digit uses the digits ‘a’, ‘b’, ‘c’, and ’d’, where a ≥ b ≥ c ≥ d (but not all equal). Consequently, we could write the formula for 4-digit Kaprekar numbers as follows:
K = abcd – dcba
Here, for the first number (from the left), ‘a’ takes the 1000’s place, ‘b’ takes the 100’s place, ‘c’ takes the 10’s place, and ‘d’ takes the 1’s place. For dcba (the second number), it is the other way around. Consequently, we could rewrite the formula as follows:
The 3-digit Kaprekar number formula — Math illustrated by the author
This relation proves that 4-digit Kaprekar numbers are also multiples of 9. Furthermore, it gives us a way to predict the Kaprekar sequence behaviour. Without this relation, we would have to create a table of the 9990 possible 4-digit numbers (leading zeroes are allowed for the Kaprekar algorithm).
At this point, you might be wondering how exactly this formula helps us. Focus on the terms (a – d) and (b -c). These are essentially the differences between the outer digits and the inner digits respectively. Let us say that m = (a – d) and n = (b – c). We could rewrite the 4-digit Kaprekar formula as follows:
K(m, n) = 999m + 90n
It turns out that multiple 4-digit numbers lead to the same (m, n) combination. A set of mathematical objects that share a common property are collectively grouped into an equivalence class.
For instance, the equivalence class for (8, 1) contains 9981, 9871, 9651, 9541, 9431, 9321, 9211, 8870, 8760, 8650, 8540, 8430, 8320, 8210, 8100, and all their permutations. This significantly reduces the number of possibilities.
Excluding numbers with the same digits, similar to (8, 1), there exist only 54 classes in total that converge to Kaprekar’s constant (6174). This makes it significantly easier to predict the behaviour of Kaprekar sequences in the 4-digit case.
If you have read this essay so far, I assume that you found all of this fascinating. So do I. But what use does this serve? Well, as far as I researched, the notion of the Kaprekar sequence does not find much use outside of cryptography. While that is a bit of a disappointment, I would say that it is a net win for mathematics even if all it ever did was create excitement amongst math-lovers.
With that, I conclude this essay and hope that you enjoyed reading it.
If you’d d like to get notified when interesting content gets published here, consider subscribing.
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
Cookie
Duration
Description
cookielawinfo-checkbox-advertisement
1 year
Set by the GDPR Cookie Consent plugin, this cookie is used to record the user consent for the cookies in the "Advertisement" category .
cookielawinfo-checkbox-analytics
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional
11 months
The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance
11 months
This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
CookieLawInfoConsent
1 year
Records the default button state of the corresponding category & the status of CCPA. It works only in coordination with the primary cookie.
viewed_cookie_policy
11 months
The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Cookie
Duration
Description
_gat
1 minute
This cookie is installed by Google Universal Analytics to restrain request rate and thus limit the collection of data on high traffic sites.
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Cookie
Duration
Description
__gads
1 year 24 days
The __gads cookie, set by Google, is stored under DoubleClick domain and tracks the number of times users see an advert, measures the success of the campaign and calculates its revenue. This cookie can only be read from the domain they are set on and will not track any data while browsing through other sites.
_ga
2 years
The _ga cookie, installed by Google Analytics, calculates visitor, session and campaign data and also keeps track of site usage for the site's analytics report. The cookie stores information anonymously and assigns a randomly generated number to recognize unique visitors.
_ga_R5WSNS3HKS
2 years
This cookie is installed by Google Analytics.
_gat_gtag_UA_131795354_1
1 minute
Set by Google to distinguish users.
_gid
1 day
Installed by Google Analytics, _gid cookie stores information on how visitors use a website, while also creating an analytics report of the website's performance. Some of the data that are collected include the number of visitors, their source, and the pages they visit anonymously.
CONSENT
2 years
YouTube sets this cookie via embedded youtube-videos and registers anonymous statistical data.
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Cookie
Duration
Description
IDE
1 year 24 days
Google DoubleClick IDE cookies are used to store information about how the user uses the website to present them with relevant ads and according to the user profile.
test_cookie
15 minutes
The test_cookie is set by doubleclick.net and is used to determine if the user's browser supports cookies.
VISITOR_INFO1_LIVE
5 months 27 days
A cookie set by YouTube to measure bandwidth that determines whether the user gets the new or old player interface.
YSC
session
YSC cookie is set by Youtube and is used to track the views of embedded videos on Youtube pages.
yt-remote-connected-devices
never
YouTube sets this cookie to store the video preferences of the user using embedded YouTube video.
yt-remote-device-id
never
YouTube sets this cookie to store the video preferences of the user using embedded YouTube video.
There is an typo in your 3-digit factoring statement. It should read “factoring 999 and 90 out” instead of “factoring 999 and 99 out”
Thank you very much for pointing this out! I have corrected the error now.