The number 6174 is truly mysterious. At first glance it may seem that there is nothing unique in it. But as we will see later, everyone who knows how to count can discover a secret that makes the number 6174 so special.
Caprecar function
In 1949, the mathematician D. R. Kaprekar from the city of Dolali (India) invented a mathematical operation, which is now known as the Caprekar function. To begin, select any number in which the digits do not repeat (that is, not 1111, 2222, etc.). Then rearrange the numbers so that you get the largest number possible and the smallest possible. Then you need to subtract from the larger the smaller - and repeat the operation with the resulting number.
This is a simple action, but Kaprekar discovered that it leads to an amazing result. Let's see how this works, for example, on the number 2005. From these figures we can get the maximum number 5200, and the minimum - 0025, that is, 25. The subtraction will look like this:
')
5200 - 0025 = 5175
7551 - 1557 = 5994
9954 - 4599 = 5355
5553 - 3555 = 1998
9981 - 1899 = 8082
8820 - 0288 = 8532
8532 - 2358 = 6174
7641 - 1467 = 6174
When we reach 6174, the function repeats itself, returning 6174 each time. We call the number 6174 a fixed point for a given function. This number causes a number of subtractions to stop, but is it really only in this? Here we are waiting for another surprise. Let's try to repeat the operation on some other number, for example, 1789.
9871 - 1789 = 8082
8820 - 0288 = 8532
8532 - 2358 = 6174
We again received 6174!

When we started from 2005, we reached 6174 in seven steps, and for 1789 the process took three steps. In fact, you get 6174 for any four-digit number in which all digits are not the same. This is amazing, isn't it? The Caprecar function is so simple, but it gives such an interesting result. And it becomes even more interesting when we think about the reasons why all four-digit numbers reach the mysterious number 6174.
Only 6174?
From the digits of each four-digit number, you can get the maximum number, if you rearrange the numbers in descending order, and the minimum number is obtained by rearranging them in ascending order. For four digits
a, b, c, d :
9 β₯ a β₯ b β₯ c β₯ d β₯ 0where
a, b, c, d are not the same digits, the maximum is
abcd , and the minimum is
dcba .
We can calculate the result of the Caprekar function, making a system of equations.
abcd
-dcba
____
ABCDwhat gives the following result
D = 10 + d - a (if a> d)
C = 10 + c - 1 - b = 9 + c - b (if b> c - 1)
B = b - 1 - c (if b> c)
A = a - dfor numbers where
a> b> c> d .
The result will start repeating if the total number
ABCD can be written with the original four digits
a, b, c and
d . So we can find a fixed point of the Caprekar function, sorting through all possible combinations
{a, b, c, d} and checking whether the above conditions are true. Each of 4! = 24 combinations gives a system of four equations with four unknowns, so we should have no problem solving this system for
a, b, c and
d .
It turns out that only one of these combinations has an integer solution that satisfies the requirement
9 β₯ a β₯ b β₯ c β₯ d β₯ 0 . This is the combination
ABCD = bdac , and the only solution to the system of equations is
a = 7, b = 6, c = 4 and
d = 1 . That is,
ABCD = 6174. For the same bits
{a, b, c, d} , the system has no valid solution. Therefore, the number 6174 is the only fixed point of the Caprekar function β our mysterious number is unique.
For three-digit numbers, the same phenomenon is observed. For example, applying the Caprekar function to the number 753 gives the following:
753 - 357 = 396
963 - 369 = 594
954 - 459 = 495
954 - 459 = 495
The number 495 is a unique fixed point for three-digit numbers, and all three-digit numbers ultimately reduce to it. You can check it yourself.
How fast is 6174?
It was about 1975 when I first heard about the number 6174 from a friend, and then I was very impressed. I thought it would be quite easy to explain the reasons for this phenomenon, but I could not find an explanation. I checked all four digits on the computer. The program took about 50 lines on Visual Basic and it checked all 8991 four-digit combinations from 1000 to 9999, where the characters are not repeated.
The table below shows the result: each number reaches 6174 maximum in seven iterations. If you have not reached 6174 in seven iterations, then you simply have an error in the calculations and you need to try again!
Iterations | Amount of numbers |
0 | one |
one | 356 |
2 | 519 |
3 | 2124 |
four | 1124 |
five | 1379 |
6 | 1508 |
7 | 1980 |
My computer program checked all 8991 numbers, but Malcolm Lines in his article [Lines, Malcolm E., A, Bristol: Hilger (1986)] proves that it is enough to check only 30 possible four-digit numbers to check the Caprecar function.
As before, let's represent four digits as
abcd , where
9 β₯ a β₯ b β₯ c β₯ d β₯ 0 .
Let's calculate the first action in the chain. The maximum number is
1000a + 100b + 10c + d , and the minimum is
1000d + 100c + 10b + a . So the subtraction operation will be reduced to the following:
1000a + 100b + 10c + d - (1000d + 100c + 10b + a)
= 1000 (ad) + 100 (bc) + 10 (cb) + (da)
= 999 (ad) + 90 (bc)A positive value
(ad) is from 1 to 9, and
(bc) is from 0 to 9. Looking through all possible options, we can see all possible results of the first subtraction action. They are shown in the table.

We are interested only in numbers in which the digits are not the same and
a β₯ b β₯ c β₯ d ,
therefore, we take only those in which
(ad) β₯ (bc) . So we can ignore the whole gray zone in the table containing the numbers in which
(ad) <(bc) .
Now we will regroup the numbers in the table in descending order to get the ready minimum number for the second subtraction.

We can ignore duplicates (gray zone) and there are exactly 30 numbers left to continue the operation. The following diagram shows the routes in which all of these numbers come to a consistent result of 6174.

From this scheme, you can see how all four-digit numbers reach 6174 and this happens in a maximum of seven iterations. But even after that, it seems to me that the number 6174 remains rather mysterious. I believe that Kaprekar, who discovered this number, was extremely clever and he had a lot of time thinking about this problem!
Two digits, five digits, six and more ...
We have already seen that four- and three-digit numbers reach a unique fixed point, but what about numbers with a different number of characters? It turns out that for them the result is not so impressive. Let's try a two-digit number, for example, 28:
82 - 28 = 54
54 - 45 = 9
90 - 09 = 81
81 - 18 = 63
63 - 36 = 27
72 - 27 = 45
54 - 45 = 9
After a short time, we will see that all two-digit numbers form a cycle 9 β 81 β 63 β 27 β 45 β 9. In contrast to the three- and four-digit numbers, there is no unique fixed point.
And what about the five-digit numbers? Is there a unique fixed point for them, such as 6174 and 495? To answer this question, we will have to do a similar operation: check all 120 combinations
{a, b, c, d, e} for
ABCDE in order to meet the conditions:
9 β₯ a β₯ b β₯ c β₯ d β₯ e β₯ 0and
abcde - edcba = ABCDE .
Fortunately, all the necessary calculations have already been done on the computer and it is known that there is no unique constant point for the Caprekar function on five-digit numbers. But all five-digit numbers are reduced to one of three cycles:
71973 β 83952 β 74943 β 62964 β 71973
75933 β 63954 β 61974 β 82962 β 75933
59994 β 53955 β 59994
As Malcolm Lynes notes in his article, it takes a lot of time to check numbers with six or more digits, and this work becomes extremely tedious. To save you from this fate, the following table contains the fixed points of all numbers from two to ten digits (for the rest, see
Mathews Archive of Recreational Mathematics ).
Discharges | Constant point |
2 | Not |
3 | 495 |
four | 6174 |
five | Not |
6 | 549945, 631764 |
7 | Not |
eight | 63317664, 97508421 |
9 | 554999445, 864197532 |
ten | 6333176664, 9753086421, 9975084201 |
Fine, but what is the reason?
We were convinced that all three-digit numbers reduce to 495, and all four-digit numbers to 6174 as a result of calculating the Caprecar function. But I did not explain why all these numbers have a unique fixed point. Is this phenomenon random or does it have a deeper mathematical explanation? It is beautiful and mysterious that this may be a mere coincidence.
Let's stop and think about a beautiful puzzle composed by Japanese author Yukio Yamamoto.
If you multiply two five-digit numbers, you can get the result 123456789. Guess these two numbers.
This is a very beautiful puzzle, and you can assume that there is some big mathematical theory behind it. But in fact, her beauty is exclusively random, there are other similar, but not such beautiful examples:

(We can give you a
hint for solving these problems, but the
answers .)
If I show you the puzzle of Yamamoto, then you will be interested in solving it, because it is beautiful, but if I show you the second puzzle, then it may not interest you at all. I think that the Kaprekar problem is similar to Yamamoto's number search problem. We like these puzzles, because they are beautiful. And for the same reason, it seems to us that there must be something more than simple coincidence in them. Such misunderstandings often led to scientific discoveries in mathematics and science of the past.
Is it enough to know that all four-digit numbers are reduced to the number 6174 as a result of the Caprekar function, but not to know why? Until now, no one could say with certainty that a unique fixed point for three- and four-digit numbers is just a random phenomenon. It seems so amazing property that we can expect that there is some big theorem from number theory behind it. If we were able to answer this question, perhaps, in the end, it would turn out that this is just a beautiful misunderstanding, but we hope that this is not so.