# The Fantastic 6174

April 1st, 2012 by Math Tricks | Filed under Mysterious Numbers.

``` // <![CDATA[ google_ad_client = "ca-pub-2176115693811858"; /* The Fantastic 6174 */ google_ad_slot = "1335742591"; google_ad_width = 468; google_ad_height = 60; // ]]&gt; // <![CDATA[ // ]]&gt; ```

### The Mystery of 6174

6174. It is a number well known to many. Some say it is mysterious, but I would not go that far. It is, however, a very interesting number. Indeed, the number 6174 is also known as the Kaprekar constant, named after the Indian mathematician Dattaraya Ramchandra Kaprekar who studied the mystery behind 6174.

So what is all the hoopla about 6174? Well, first, if you arrange the digits such that you have the highest number (7641) and also the lowest number (1467), and then determine the difference between the two, you arrive at 6174 (7641 – 1467 = 6174).

Well you say, I suppose this is somewhat interesting. But now suppose you take the number 2355. Do what you did before with 6174 – rearrange the numbers to obtain the highest and lowest numbers, and then subtract the lowest from the highest:

2355 -> 5532, 2355
5532 – 2355 = 3177

Now continue the process with the result:

3177 -> 7731, 1377
7731 – 1377 = 6354

And again:

6354 -> 6543, 3456
6543 – 3456 = 3087

Continuing:

3087 -> 8730, 0378
8730 – 378 = 8352

8352 -> 8532, 2358
8532 – 2358 = 6174

As you can see, this process leads to a convergence to 6174. And as you saw before, performing this routine on 6174 results in an endless loop. Cool!

In fact, this same result will occur for any four digit number you choose as long as the number isn’t composed of the same digit (eg., 4444 would not work). You can even use leading zero’s for your four digit number (eg., 0007). Now that is interesting!

Let’s try another example, one with a lot of zeros – 3000:

3000 -> 3000, 0003
3000 – 3 = 2997

2997 -> 9972, 2799
9972 – 2799 = 7173

7173 -> 7731, 1377
7731 – 1377 = 6354

6354 -> 6543, 3456
6543 – 3456 = 3087

087 -> 8730, 0378
8730 – 378 = 8352

8352 -> 8532, 2358
8532 – 2358 = 6174

It is this process that was discovered by our Indian friend Kaprekar, and is known as Kaprekar’s routine. There are other similar numbers that are obtained for other n-digit numbers. For example, for three digit numbers, this process leads to a convergence to 495. Using the routine on two digit numbers results in an infinite loop:

9 -> 81 -> 63 -> 27 -> 45 -> 9

As an interesting experiment, you are invited to try to determine what happens if you perform this routine on higher digit numbers. You may be surprised to see what your results are!

### 4 Responses to “The Fantastic 6174”

1. Garrett Hildebrand | 3/04/12

I created a program to go through all 10,000 possible numbers. What I found out is that there are 383 numbers that when factored-out (high digits to low, low digits to high) yield 20 unique pairs that produce the Kaprekar constant in one subtraction. I also found out that there are certain numbers that take 7 iterations of the algorithm to produce the expected result. This was an unexpected side-benefit of my wondering, “how many of the 10,000 possible numbers produce a zero result?”

I have found that exactly 80 numbers will produce a zero result with this process (including ones such as 1111, 2222,
3333, etc., that we already knew about).

Here are 8 in the 2xxx range:

2111
2122
2212
2221
2222
2223
2232
2322
2333

There are only 4 in the 9xxx range:

9888
9899
9989
9998

If you are interested in all the details of this, send me an email. I wrote the whole thing up with all numbers included to share with some friends who are into math. But it is kind of long to post here. I would also be glad to share the program. It is written in Perl.

2. Garrett Hildebrand | 4/04/12

I now agree with the statement that with the exception of numbers composed of the same digit (only 10 of them), all others will yield 6174. That makes this number even more remarkable to me!

The zero results I was seeing turn out to be a bug in my code.

What was happening is that although I made sure the initial number was R#4 (right-justified in a field of zeroes), I was not doing this on the subtraction result. Consequently, certain number combinations would yield 999 as a result (for example, 5554 and 5556). So instead of subtracting 999 from 9990, it was subtracting 999 from 999.

3. Lesego | 12/04/12

I’m not a mathematician or anything but I do find this very interesting.

I would like help with solving the equation (if there is any) to get the other n-digit numbers.

2-digits : 9 or the loop shown
3-digits : 495
4-digits : 6174
5-digits : 61974
6-digits : 851742

I’m trying to find the equation that can give me the numbers for any number of digits (nth-digit).

I’m not sure of it exists but I’m trying to incorporate 9 in the equation. Please help.

Thanks :)

4. Mike | 18/06/12

While I haven’t devoted a ton of time on this, I did run the exercise by hand up through 6 digits and happy to report as Lesego posted the results.
2-digits : 9
3-digits : 495
4-digits : 6174
5-digits : 61974
6-digits : 851742

What I’m wondering is: What do these resultant numbers have in common? Is there some formula that can derive any n-number sequence without going through the algorithm of multiple re-arrangements and subtractions?

Prove you are human - or a smart monkey! * Time limit is exhausted. Please reload CAPTCHA.