Mysterious number 6174

Yutaka Nishiyama
March 2006

Anyone can uncover the mystery

Anyone can uncover the mystery

The number 6174 is a really mysterious number. At first glance, it might not seem so obvious. But as we are about to see, anyone who can subtract can uncover the mystery that makes 6174 so special.

Kaprekar's operation

In 1949 the mathematician D. R. Kaprekar from Devlali, India, devised a process now known as Kaprekar's operation. First choose a four digit number where the digits are not all the same (that is not 1111, 2222,...). Then rearrange the digits to get the largest and smallest numbers these digits can make. Finally, subtract the smallest number from the largest to get a new number, and carry on repeating the operation for each new number.

It is a simple operation, but Kaprekar discovered it led to a surprising result. Let's try it out, starting with the number 2005, the digits of last year. The maximum number we can make with these digits is 5200, and the minimum is 0025 or 25 (if one or more of the digits is zero, embed these in the left hand side of the minimum number). The subtractions are:

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 operation repeats itself, returning 6174 every time. We call the number 6174 a kernel of this operation. So 6174 is a kernel for Kaprekar's operation, but is this as special as 6174 gets? Well not only is 6174 the only kernel for the operation, it also has one more surprise up its sleeve. Let's try again starting with a different number, say 1789.

9871 - 1789 = 8082
8820 - 0288 = 8532
8532 - 2358 = 6174

We reached 6174 again!

6174: a very mysterious number...

A very mysterious number...

When we started with 2005 the process reached 6174 in seven steps, and for 1789 in three steps. In fact, you reach 6174 for all four digit numbers that don't have all the digits the same. It's marvellous, isn't it? Kaprekar's operation is so simple but uncovers such an interesting result. And this will become even more intriguing when we think about the reason why all four digit numbers reach this mysterious number 6174.

Only 6174?

The digits of any four digit number can be arranged into a maximum number by putting the digits in descending order, and a minimum number by putting them in ascending order. So for four digits a,b,c,d where

9 ≥ a ≥ b ≥ c ≥ d ≥ 0

and a, b, c, d are not all the same digit, the maximum number is abcd and the minimum is dcba.

We can calculate the result of Kaprekar's operation using the standard method of subtraction applied to each column of this problem:

a b c d
- d c b a


which gives the relations

D = 10 + d - a (as a > d)
C = 10 + c - 1 - b = 9 + c - b (as b > c - 1)
B = b - 1 - c (as b > c)
A = a - d

for those numbers where a>b>c>d.

A number will be repeated under Kaprekar's operation if the resulting number ABCD can be written using the initial four digits a,b,c and d. So we can find the kernels of Kaprekar's operation by considering all the possible combinations of {a, b, c, d} and checking if they satisfy the relations above. Each of the 4! = 24 combinations gives a system of four simultaneous equations with four unknowns, so we should be able to solve this system for a, b, c and d.

It turns out that only one of these combinations has integer solutions that satisfy 9 ≥ a ≥ b ≥ c ≥ d ≥ 0. That combination is ABCD = bdac, and the solution to the simultaneous equations is a=7, b=6, c=4 and d=1. That is ABCD = 6174. There are no valid solutions to the simultaneous equations resulting from some of the digits in {a,b,c,d} being equal. Therefore the number 6174 is the only number unchanged by Kaprekar's operation — our mysterious number is unique.

For three digit numbers the same phenomenon occurs. For example applying Kaprekar's operation to the three digit number 753 gives the following:

753 - 357 = 396
963 - 369 = 594
954 - 459 = 495
954 - 459 = 495

The number 495 is the unique kernel for the operation on three digit numbers, and all three digit numbers reach 495 using the operation. Why don't you check it yourself?

How fast to 6174?

It was about 1975 when I first heard about the number 6174 from a friend, and I was very impressed at the time. I thought that it would be easy to prove why this phenomenon occurred but I could not actually find the reason why. I used a computer to check whether all four digit numbers reached the kernel 6174 in a limited number of steps. The program, which was about 50 statements in Visual Basic, checked all of 8991 four digit numbers from 1000 to 9999 where the digits were not all the same.

The table below shows the results: every four digit number where the digits aren't all equal reaches 6174 under Kaprekar's process, and in at most seven steps. If you do not reach 6174 after using Kaprekar's operation seven times, then you have made a mistake in your calculations and should try it again!

Iteration Frequency
0 1
1 356
2 519
3 2124
4 1124
5 1379
6 1508
7 1980

Which way to 6174?

My computer program checked all 8991 numbers, but in his article Malcolm Lines explains that it is enough to check only 30 of all the possible four digit numbers when investigating Kaprekar's operation.

As before let's suppose that the four digit number is abcd, where

9 ≥ a ≥ b ≥ c ≥ d ≥ 0.

Let us calculate the first subtraction in the process. The maximum number is 1000a+100b+10c+d and the minimum number is 1000d+100c+10b+a. So the subtraction is:

1000a + 100b + 10c + d - (1000d + 100c + 10b + a)
= 1000(a-d) + 100(b-c) + 10(c-b) + (d-a)
= 999(a-d) + 90(b-c)

The possible value of (a-d) is from 1 to 9, and (b-c) is from 0 to 9. By running through all the possibilities, we can see all the possible results from the first subtraction in the process. These are shown in Table 1.

Table 1: Numbers after the first subtraction in Kaprekar's process

Table 1: Numbers after the first subtraction in Kaprekar's process

We are only interested in numbers where the digits are not all equal and

a ≥ b ≥ c ≥ d,

therefore we only need to consider those where (a-d) ≥ (b-c). So we can ignore the grey region in Table 1 which contains those numbers where

(a-d) < (b-c).

Now we arrange the digits of the numbers in the table in descending order, to get the maximum number ready for the second subtraction:

Table 2: Maximum numbers, ready for the second subtraction

Table 2: Maximum numbers, ready for the second subtraction

We can ignore the duplicates in Table 2 (the grey regions), and are left with just 30 numbers to follow through the rest of the process. The following figure shows the routes which these numbers take to reach 6174.

How these 30 numbers reach 6174

How these 30 numbers reach 6174

From this figure you can see how all the four digit numbers reach 6174 and reach it in at most seven steps. Even so I still think it is very mysterious. I guess Kaprekar, who discovered this number, was extremely clever or had a lot of time to think about it!

Two digits, five digits, six and beyond...

We have seen that four and three digit numbers reach a unique kernel, but how about other numbers? It turns out that the answers for those is not quite as impressive. Let try it out for a two digit number, say 28:

82 - 28 = 54
54 - 45 =   9
90 - 09 = 81
81 - 18 = 63
63 - 36 = 27
72 - 27 = 45
54 - 45 =   9

It doesn't take long to check that all two digit numbers will reach the loop 9→81→63→27→45→9. Unlike for three and four digit numbers, there is no unique kernel for two digit numbers.

But what about five digits? Is there a kernel for five digit numbers like 6174 and 495? To answer this we would need to use a similar process as before: check the 120 combinations of {a,b,c,d,e} for ABCDE such that

9 ≥ a ≥ b ≥ c ≥ d ≥ e ≥ 0


abcde - edcba = ABCDE.

Thankfully the calculations have already been done by a computer, and it is known that there is no kernel for Kaprekar's operation on five digit numbers. But all five digit numbers do reach one of the following three loops:


As Malcolm Lines points out in his article, it will take a lot of time to check what happens for six or more digits, and this work becomes extremely dull! To save you from this fate, the following table shows the kernels for two digit to ten digit numbers (for more see Mathews Archive of Recreational Mathematics). It appears that Kaprekar's operation takes every number to a unique kernel only for three and four digit numbers.

Digits Kernel
2 None
3 495
4 6174
5 None
6 549945, 631764
7 None
8 63317664, 97508421
9 554999445, 864197532
10   6333176664, 9753086421, 9975084201

Beautiful, but is it special?

We have seen that all three digit numbers reach 495, and all four digit numbers reach 6174 under Kaprekar's operation. But I have not explained why all such numbers reach a unique kernel. Is this phenomenon incidental, or is there some deeper mathematical reason why this happens? Beautiful and mysterious as the result is, it might just be incidental.

Let's stop and consider a beautiful puzzle by Yukio Yamamoto in Japan.

If you multiply two five digit numbers you can get the answer 123456789. Can you guess the two five digit numbers?

If you multiply two five digit numbers you can get the answer 123456789. Can you guess the two five digit numbers?

This is a very beautiful puzzle and you might think that a big mathematical theory should be hidden behind it. But in fact it's beauty is only incidental, there are other very similar, but not so beautiful, examples. Such as:

If you multiply two five digit numbers you can get the answer 123456784. Can you guess the two five digit numbers?

(We can give you a hint to help you solve these puzzles, and here are the answers.)

If I showed you Yamamoto's puzzle you would be inspired to solve it because it is so beautiful, but if I showed you the second puzzle you might not be interested at all. I think Kaprekar's problem is like Yamamoto's number guessing puzzle. We are drawn to both because they are so beautiful. And because they are so beautiful we feel there must be something more to them when in fact their beauty may just be incidental. Such misunderstandings have led to developments in mathematics and science in the past.

Is it enough to know all four digit numbers reach 6174 by Kaprekar's operation, but not know the reason why? So far, nobody has been able to say that all numbers reaching a unique kernel for three and four digit numbers is an incidental phenomenon. This property seems so surprising it leads us to expect that a big theorem in number theory hides behind it. If we can answer this question we could find this is just a beautiful misunderstanding, but we hope not.

Note from the editors: many readers noticed that repeatedly adding up the digits of any of the kernels of Kaprekar's operation always equals 9. Find out why in this follow-up to the article.


  • Kaprekar, D. R., "Another Solitaire Game", Scripta Mathematica, vol 15, pp 244-245 (1949)
  • Gardner, Martin, "The Magic Numbers of Doctor Matrix", Japanese version, Tokyo: Kinokuniya (1978)
  • Lines, Malcolm E., A number for your thoughts: facts and speculations about numbers..., Bristol: Hilger (1986)
  • Nishiyama, Yutaka, Kurashi no Algorithm, Kyoto: Nakanishiya (1993)

    About the author

    Yutaka Nishiyama is a professor at Osaka University of Economics, Japan. After studying mathematics at the University of Kyoto he went on to work for IBM Japan for 14 years. He is interested in the mathematics that occurs in daily life, and has written seven books about the subject. The most recent one, called "The mystery of five in nature", investigates, amongst other things, why many flowers have five petals. Professor Nishiyama is currently visiting the University of Cambridge.


visual basic didn't exist in 1975

Yes, visual basic didn't exist in 1975.
I tested it by FORTRAN program in those days and recently test again by visual basic or visual studio.
Yutaka Nishiyama

I almost stopped reading and left the page at the point you seemed to imply that in 1975 there was extant visual basic. I am so glad I kept on reading.

Thank you for taking the time to put all this together. A very interesting read, I appreciate the time you took to make it. Nice pictures and diagrams too!

BASIC was the programming taught to me in High School 1974, with a audio coupler, teletype & papertape....

I'd like to see what happens to 11-20 digit numbers. What is the limit for which the kernel has been found? thank you


Have they missed something about the 495 being a kernel for 3 digits only?

You get this number from 4 digits as well

try any 4 digit number in pairs divided by one another for example 5858 or 1919 and then deduct 5588 or 1199 and u will get to 495 in not time

In Mathematica. But no kernels found :(

num = 10^n - 2;
t = Table[
num = (num // IntegerDigits // Sort // Reverse //
FromDigits)*(10^((n - (num // Log10)) // Floor)) - (num //
IntegerDigits // Sort // FromDigits), {x, 0, 50}] //
ListPlot, {n, 2, 40, 1}]

... also, has there been any investigation as to why the digits need to be different? Clearly, this works for some numbers with repeating digits, eg

9871 - 1789 = 8082 -> since 9871 reaches 6174 so much 8082

thank you

The criteria wasn't "no repeating" digits -- just " not all repeating." In other words, you can't use 1111,2222,3333,4444,5555,6666,7777,8888, or 9999 for obvious reasons (the largest and smallest numbers would be the same and so the first subtraction would yield zero). But any other 4-digit combination should work -- so 1112 or 1311 or whatever would be fine.

Actually 1112 doesn’t work:

2111-1112 = 999

Actually 1112 does work:

2111-1112 = 999
9990 - 0999 =
8532 - 2358 = 6174
5 iterations.


You also get 495 from any 4 digit number made of pairs for example 1919 and then deducting 1199 you get to 6174 in not time so I dont see any wonder on this!

The wonder I see is you swap this digits by starting with the higher number in front example 9191 -deducting 1199 and you end up with 6174:))))

Very nice article, I enjoyed it
(who cares whether visual basic existed in 1975 or not)

What happens if this experiment is repeated with different bases such as octal (0-7) hex (0-f) or binarry (0,1)?

I also saw the VB error but it did not detract from the subject in anyway. Again thanks for sharing.

Very nice article.
For a non mathematician, I struggled for quite a while through the 4 lines of relations (e.g. trying to figure out how b had to be greater than c for the third one), it was only later that I read 'for those numbers where a>b>c>d'. Maybe that should go first?
Also am curious about how the iterations play out in non decimal bases?

Is it true that every number of digits that is a prime number has no kernel? Like, will a number of 11 digits have a "None"?

No, it is not. Three is a prime, and has a kernel.

3 is the only odd prime that is related to 9 by virtue of it being its divisor. All subsequent primes don't have any correlation with 9. Just the test on 11 will tell us by means of falsification if the hypothesis holds good.

More mystery or am I just making it up? The digits 6172 "appears" in the list of kernels for all numbers with a length which is even (greater than 3), 6174 for 4 digits, 631764 for 6 digits, 63317664 for 8 digits and 6333176664 for 10 digits. Does this mean 633331766664 is a possible kernel for numbers with 12 digits?


There's an interesting fact about the 10-digit kernels, if you try looping '1234567890' around it also comes back!

Hi there,

How does your calculation work?

I see your result:
Iteration Frequency
0 1
1 356
2 519
3 2124
4 1124
5 1379
6 1508
7 1980

But, my test gives:
[0] => 1
[1] => 356
[2] => 519
[3] => 2124
[4] => 1124
[5] => 1311
[6] => 1508
[7] => 1980
[10] => 68

See the difference on the 5th iteration. When I look back, this resulted from the following digits:

A random test with 3433 gives:
#1: 4333 - 3334 = 999
#2: 999 - 999 = 0
#3: 0 - 0 = 0
#4: 0 - 0 = 0
#5: 0 - 0 = 0
#6: 0 - 0 = 0
#7: 0 - 0 = 0
#8: 0 - 0 = 0
#9: 0 - 0 = 0
#10: 0 - 0 = 0

Can you clarify this? Maybe my calculations are wrong.
Thank you.

Your step #2 is incorrect. The result from step #1 is 0999. So step #2 should be 9990 - 0999 = 8991. If you continue on from there, you'll see that it works out.

999 should be 9990 and 0999 there must be 4 digits in order for it to work. your #2 only has 3 digits.

#2: 999 - 999 = 0 <---- 0999 - 9990 = 8991
9981 - 1899 = 8082
8820 - 0288 = 8532
8532 - 2358 = 6174
7641 - 1467 = 6174
7641 - 1467 = 6174
7641 - 1467 = 6174
7641 - 1467 = 6174 :)

my bast regards
maher - Saleh

4333 - 3334 = 999 is correct but need to keep 4 digits so write 0999
then you get:
9990-0999=8991 and so on.

Though mathematics is not my forte I found your artical interesting. As a Forester I was drawn to your the title of your book "The mystry of five in nature". My mind went to the biology term- 'Contact Parastikeits' (spelling may be off) which follows Fibonaccis sequence 1,1,2,3,5,8... Have you found the "Mystery" to follow this sequence?

Dave Peckham

Hi Dave,

You can find out more about the Fibonacci sequence here:

Article about Five Petals is there,
My approach is without Fibonaccis sequence.

Yutaka Nishiyama

Hello, when i was playing with numbers. i played with 2 digit numbers and i saw that always, or at least the many times i have done it. i came to a number that is a multypile of 9. is it true or i just got lucky?

The difference between 2 numbers wil the same digits will always be a multiple of 9.
Consider a 2 digit number as 10x + y. Transpose the digits; 10y + x. (10x + y) - (10y + x) = 9x - 9y.

that is true!

your result really works and it was intersting to see

for six digit numbers, you may get into an infinite loop. Try 851742

875421 - 124578 = 750843
875430 - 34578 = 840852
885420 - 24588 = 860832
886320 - 23688 = 862632
866322 - 223668 = 642654
665442 - 244566 = 420876
876420 - 24678 = 851742

What happens when the base is changed? Do we get different solutions for different number of digits?

This is essentially the Fibonacci sequence with the decimal place moved over to the right one time.

All the Kaprekar kernels or kernel loop-numbers are multiples of 9.

For all Kaprekar's constants with an even number of digits, the average of the digits in that number is ALWAYS 4.5!

9*9= 81 ; 8+1 = 9!

45*45= 2025 ; 20 +25 = 45 !

55*55 = 3025 ; 30 + 25 = 55!

99*99= 9801 ; 98+01 = 99!

703*703= 494209 ; 494+209= 703!

5292*5292 = 28005264 ; 28+ 005264 = 5292!

This magic can also be seen on 2728, 857143 etc...

using numbers 0-9 and letters a-z what is the breakdown and mathematical structure for this. Im good at math just not on a deep level like this. Please help. contact me

Dear Readers,
I've just published new book entitled "The Mysterious Number 6174: One of 30 Amazing Mathematical Topics in Daily Life,"
ISBN 978-4768761748.
Please check it at Amazon Japan, and my website is at
Prof. Yutaka Nishiyama

every one of the kernels is divisible by 9.

I would think 9 is the absolute root kernel number.
on the two digit example the sum adds up to 9.
if you add 6174 you get 18 thus 9.

even further you can take 9 down to 3.
the mystery of 5 is in the sacred geometry of the golden ratio.
which is a simple mathematical explanation of remaining numbers and the outward spiral and unfolding of the universe mathematically. five is a spiral symbolically. and in five there are three elements and two polar opposites thus 2:3=5 or 1:1:2:3:5 two and three make five but not one and one. this on whole two polars and three elements.?
I'd like to know more......

The article says the same phenomenon occurs with three digit numbers.
Well, this does not seem to be true.
Try with 321 and you'll see it loops...

Are you sure about that? When I calculated beginning with 321, the steps went as follows: 321, 198, 792, 693, 594, 495.

Please check the number 6086

In my calculation (all the possible numbers for these four digits) takes up to nine steps to reach 6174 ; which itself is a multiple of 9.
Now why only this takes up to ninth step may be important.

I don't know why; but I have a feeling that it has to do something with the following math puzzle:

1. Take up a number of any digit length.
2. Leave 18 rows empty.
3. write in the 20th row sum of all these unfilled numbers.
4. The sum would always be reached by adding 9 to left of the number in first row; taking rest of the digits same till tens then subtract 9 from the ones. ( Or You may require to adjust the tens with this subtraction.)
5. Then ask the person you're playing with to write another number in second row of same digit length as first.
6. Then in third row you write your number as to make the sum of two rows as 9,99,999,9999....

For Instance:
My friend take up a number 2986.
I would leave another 18 row empty. In row # 20 I write the answer: 92977
now in second row my friend wrote 3342; while I write in 6657 in row # 4 (sum of row # 3 & 4 is 9999)
then repeat the same process 09 more times (first he write a number then I write mine to make the two row sum to be 9999)
Now go check the total which was written long before the whole series of numbers has been written.

2986 My Friend
3342 My Friend
6657 Me
1234 My Friend
8765 Me
0000 My Friend
9999 Me
0932 My Friend
9067 Me
9876 My Friend
0123 Me
1111 My Friend
8888 Me
5003 My Friend
4996 Me
0001 My Friend
9998 Me
2000 My Friend
7999 Me

Please let me know; if this has something to do with 6174. And 6174 divided by 9 gives 686. may be this has something to do too.
Because each new derived number is multiple of nine and hence we reach multiple 686 times to get to 6174.

Kashif Ali Qureshi
Dubai, United Arab Emirates

Hi Kashif,
I saw your post and your question as to whether the math trick has anything to do with the number 6174. It doesn't. The trick is based on adding a complementary value to each of your friend's values to ensure that the final sum will be the same as the predicted sum. I'll explain why.

The predicted sum will always be accurate because it's fixed that way, by the choice of the number you always add under your friend's number to make it add up to a number composed of all 9's.

So let 'n' denote the number of digits in the number on line 1.

There will be 18 blank lines below this number.
The final sum is predicted as 9<digits of original number up until the final two, final two digits - 9>.

Each of the 9 pairs of numbers (your friend's and yours) will always be n 9's long, as defined by your rules because you're choosing YOUR number to make this happen, dependent on the number your friend writes down.
This means that there will be 9 pairs of numbers whose sum is composed of n 9's. Which is the same as saying there will be 9 pairs whose sum is 10^n - 1, which is 9 * (10^n - 1), which is the same as inserting a 9 to the beginning of the original number, and then subtracting 9 from the result.

In other words, for a 4 digit number, you're making each pair of numbers add to 10000 - 1 = 9999, and this is the same as adding 10000 nine times, and then subtracting 1 nine times, once for each pair of numbers (your friend's and yours). So you end up adding 90000 and then subtracting 9, which you do in step 4.

For example, with a 4 digit number (like in your example), where w, x, y and z can be any 4 digits, and wxuv is the number wxyz minus 9 as you describe in step 4, and you get this:
line 1: wxyz
line 2 & 3:+ 9999 = 10000 - 1 your friend's number + your number : 9999 = 10000 - 1
line 4 & 5:+ 9999 = 10000 - 1 your friend's number + your number : 9999 = 10000 - 1
line 6 & 7:+ 9999 = 10000 - 1 your friend's number + your number : 9999 = 10000 - 1
line 8 & 9:+ 9999 = 10000 - 1 your friend's number + your number : 9999 = 10000 - 1
line 10 & 11:+ 9999 = 10000 - 1 your friend's number + your number : 9999 = 10000 - 1
line 12 & 13:+ 9999 = 10000 - 1 your friend's number + your number : 9999 = 10000 - 1
line 14 & 15:+ 9999 = 10000 - 1 your friend's number + your number : 9999 = 10000 - 1
line 16 & 17:+ 9999 = 10000 - 1 your friend's number + your number : 9999 = 10000 - 1
line 18 & 19:+ 9999 = 10000 - 1 your friend's number + your number : 9999 = 10000 - 1
------ ------ ---
line 20: 9wxuv = wxyz + 90000 - 9 which is what your forced prediction of the sum is.

I hope this helps explain why your math trick results in the predicted sum the way it does. Good luck in life and I hope your interest in math never fades.

When I was at college in the '80 in Derbyshire this was something our computer studies teacher talked about, he had read an article in a forth magazine about this and described it as being 6174 as the center of a series of concentric rings when plotted as a scatter diagram.

After listening to him prattle on about it for so long I eventually set out to prove that he didn't know what he was talking about (not unusual). So on the first day I wrote a program to calculate the route to 6174 for all 4 digit numbers, unfortunately I only had 32k of ram on my home machine and no floppy and I also needed 20k for high resolution graphics. Clearly since any calculation with the same digits would yield the same result I used 4 different FOR loops to reduce the storage requirement.
for a= 9 to 0
for b= a to 0
for c= b to 0
for d =c to 0
This allowed me to store and plot the results and it was nothing like as described. Apparently, my teacher explained the scatter diagrams had been rotated to make the plot of concentric rings, LOL

Anyway I said to my teacher that next I would plot the steps for all 4 digit numbers as the start of my proof investigation, when I came into college the following day my teacher said that he has passed my original ideas to the high level course and my work was a waste of time. I pointed out that in their plot they found that most numbers were not a route to 6174 and so were a jumble this as I had discussed the problem with my father who pointed out that the result of this operation is always a multiple of the base -1. Again I was finding storage a problem so I used the model discussed in the forth magazine to keep things simple, i.e. order digits high to low then reading left to right subtract 4rd digit from 1st and 3rd from second so for 7641 that would give the model 62. All numbers with model 62 in base 10 give 6174 as a result in 1 operation. Other models also share the same number of steps to reach that number. So plotting just the models you can see a much smaller graph and this moved me closer to being able to say how many steps would be required before reaching 6174.

So my question is, has anyone else produced the proof for this and answered why the numbers act this way to reach 6174 and also why 5 digits for example make a ring instead of a single number? after my experiences with my teacher I haven't published or discussed my own work on this with anyone else.