Hacker News new | past | comments | ask | show | jobs | submit login
Mysterious number 6174 (maths.org)
188 points by shii on June 6, 2011 | hide | past | favorite | 64 comments



I find Kaprekar's operation totally uninteresting because it is (or at least seems to me) totally linked to base ten representation of numbers.

If at least you had a result like "in any base, the analogue of Kaprekar's operation in that base has a fixed point for digits of length 3 or 4 only", it would be mildly interesting. But as it is it's not math, just senseless symbol manipulation.


This reminds me of a beautiful and appropriate comic by Cowbirds in Love:

http://cowbirdsinlove.com/43


"Recreational mathematics". Don't take it too seriously, the practitioners don't either.

But yes, the fact that this is bound to a decimal system suggests that there are no deep wisdoms here.


I don't have anything against recreational math; I rather like it myself. But, IMHO, the fact that something is tied to the representation of numbers removes it from the realm of "math".


I'd say that the representation of numbers is an important part of math.

That said, I'd agree that decimal is not a particularly interesting part of math. For reals, continued fractions are probably the most interesting representation, and have nicer mathematical properties, at that.


To the extent that 'regular' mathematicians pay attention to these things (which a good number do), I don't think it's because decimal representations are inherently that interesting, but more because some of the number-theoretic and meta-mathematical questions are interesting and yet a bit puzzling. We don't yet really have a great handle on proof techniques and understanding of these kinds of problems: why should some simple-to-state claims about integers and iterated operations on them be true, and others false, and why are some seemingly true ones so hard to prove (like the Collatz conjecture)? The fact that this one is about rearranging digits in base-10 integers is just an intuitively-appealing way of stating simple properties, but the interesting thing isn't really about the base-10-ness imo.


Perhaps you should set out to prove or disprove that conjecture, instead of writing an uninteresting post that is just senseless symbol manipulation linked to the base-26 representation of English.


It looks like this essay is saying that 6174 is a fixed point for Kaprekar's operation on four-digit numbers.

http://en.wikipedia.org/wiki/Fixed_point_(mathematics)


In fact, it says that 6174 is more than just a fixed point, it is also the only fixed point, and an attracting fixed point. That is, every four digit number with transform to 6174 in finite (indeed, less than 7) steps under Kaprekar's operation.

This is significantly stronger than just being a fixed point. As an analogy, when modeling population dynamics, one often finds both stable and non-stable equilibrium solutions. The stable ones are the only solutions that can occur in nature, and so their stability is an important thing to note. This stability often (I hesitate to say always) is the result of the solution having the same attractive nature as 6174 does.


Another fixed point of the operation is zero, which is reached in a single step if you start with a number with all the same digits (1111, for example.) Zero is stable and attracting, it just has a very small basin of attraction.


If you want to see precisely which numbers lead to which fixed points, and in how many steps, I've posted it here for all 4-digit numbers:

http://pastebin.com/3iXT777N


Here's a plot: http://imageshack.us/f/192/stepsd.png/

It might be interesting to plot the mapping instead.

edit: one has already been made: http://news.ycombinator.com/item?id=2626879


Thanks, but there's a bug in your code/results - for example, 1011 does not converge to 0, it does hit 6174 in 5 steps. Only 1111, 2222, etc. yield 0.

I suspect the handling of 3-digit values. I also slipped there at first ;-)


For 1011, the next step is 1110 - 0111 = 999, and then... apparently you're supposed to handle that as 9990 - 0999, rather than 999 - 999. Huh. I see.

But I'm inclined to consider that a bug in the definition, rather than in the code. :-} The four-digit-ness came from applying the operation to four-digit numbers, and saying "oh yeah and we'll zero-extend the results to four digits" introduces an ugly element of redundancy.

However, we can make it not ugly anymore by making "zero-extend everything to make it be 4 digits" the primary condition. Instead of applying it to 4-digit numbers, we'll make every number have 4 digits and then apply the Kaprekar procedure. So we'll now be working with the numbers 0000-9999, rather than 1000-9999. (There's no way to zero-extend numbers bigger than 9999 to be 4 digits, so that's all.) Here are the results for 0000-9999:

http://pastebin.com/TQ3cMshV

I think the frequencies of the number of steps to equilibrium are somewhat nicer, as well, when you count 0000-0999. As a simple metric, they have more factors of small primes, especially 2.

  1000-9999:
  0 steps:    1 =   1
  1 steps:  365 =   5 *  73
  2 steps:  519 =   3 * 173
  3 steps: 2124 = 2^2 * 3^2 *  59
  4 steps: 1124 = 2^2 * 281
  5 steps: 1379 =   7 * 197
  6 steps: 1508 = 2^2 *  13 *  29
  7 steps: 1980 = 2^2 * 3^2 *   5 *  11

  0000-9999:
  0 steps:    2 =   2
  1 steps:  392 = 2^3 * 7^2
  2 steps:  576 = 2^6 * 3^2
  3 steps: 2400 = 2^5 *   3 * 5^2
  4 steps: 1272 = 2^3 *   3 *  53
  5 steps: 1518 =   2 *   3 *  11 *  23
  6 steps: 1656 = 2^3 * 3^2 *  23
  7 steps: 2184 = 2^3 *   3 *   7 *  13


I am drawn to wonder if there is a discrete limit operation, and taking the discrete limit of Kaprekar's operation on all 4-digit numbers yields 6174.

My mastery of fixed-point mathematics is rusty, so I am unsure if that is identical to the above...



Seems like it! Cool, thanks.

(At work, so can't say definitely yes/no without studying).


This is indeed very interesting, but it's no surprise that it's just incidental. This and similar phenomena are just artifacts of our base-10 number system.


Made a visualization: x coordinate is the initial numbers, y coordinates are the "intermediate" numbers hit on the way to 6174. Diagonal is obviously the plot of the starting numbers. :-)

http://i.imgur.com/DfxRB.png


Have you compared this visualization with the one for 495 and with the two digit numbers?



Kaprekar's operation on binary numbers behaves in a much more predictable fashion - for example, under Kaprekar's operation on N digit binary numbers, 2^(N-1) - 1 is always a fixed point.


If you look close enough, all those "special" numbers are divisible by 9.

I made a quick experiment with other bases.

3-digits numbers, base 8 has fixed point 374_8=252_10. 252 `mod` 7 = 0.

base-9, base-11 and base 13 seem do not have fixed points.

base-12, 3 digits has (at least one) fixed point 5b6_12 = 858_10. 858 `mod` 11 = 0.

I think, it exploits some properties of positional notation of numbers so that fixed points all divisible by (base-1).


Not just the special numbers.

Kaprekar's operation always results in a multiple of 9.

Given a > b > c > d. Kaprekar's operation gives:

    1000a + 100b + 10c + d - (1000d + 100c + 10b + a)
    =999(a - d) + 90(b - c)
    =9(111(a - d) + 10(b - c))
And so on for integers with other numbers of digits.


Any number subtracted from a re-arrangement of the digits results in a multiple of 9.


Why?


A number is the sum of its digits, raised to the appropriate powers

    Sum(i=0..n, a[i]*10^i)
123, for example is 3 + 2 * 10 + 1 * 100.

A power of 10 (10^n) can be re written as

    (1 + 9 * Sum(i=0..n-1, 10^i). 
For example: 1000 = 1 + 999 = 1 + 900 + 90 + 9

When you subtract two numbers with the same digits, you end up being able to factor a nine out of these sums fairly easily.

I wrote a proof of the number - reverse(number) a while back. It can be found on archive.org

http://web.archive.org/web/20050314023901/http://jimfl.tense...


Some related references:

http://mathworld.wolfram.com/KaprekarRoutine.html

http://en.wikipedia.org/wiki/6174_(number)

The Wolfram link contains a list of Kaprekar numbers and Kaprekar sequences in common bases.


"The program, which was about 50 statements in Visual Basic, checked all of 8991 four digit numbers from 1000 to 9999..."

Whoa, you need 50 statements in VB for that? I need 14 in Python:

    import collections

    def kaprekar(k):
        nr = 0
        while True:
            if k == 6174: return nr
            small = int("".join(sorted(list("%04d" % k))))
            large = int("".join(sorted(list("%04d" % k), reverse=True)))
            k = large - small
            nr += 1
    
    freqs = collections.defaultdict(int)        
    for i in range(1000, 10000):
        if not i % 1111: continue # skip 1111, 2222, etc...
        freqs[kaprekar(i)] += 1

    for k,v in freqs.items():
        print k, v
Outputs:

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


And somebody programming in some other language might need even less lines. What's your point?


Every number is special. Every number has something on where you can apply rules to, and thus makes it special. Is there a database containing all the numbers and a list of atributes that make them special?



Only applies to integers. Most real numbers are not interesting.


Unless you assume the well-ordering principle.


That only makes them interesting relative to a given well-ordering. Since nobody knows the details of any well-ordering of the real numbers, this severely limits the interestingness of a given real number.


If you're looking for purely mathematical facts, there's a list of something "special" about each number from 0 to 9999 at http://www2.stetson.edu/~efriedma/numbers.html.

For smaller numbers, Wikipedia is pretty good too.


  "8833 = 88^2 + 33^2"
Hey, that's cheating! (Yes, I went through over eight thousand numbers to find that one.)


All the numbers? ALL of them? :)


There's an old mathematics joke proving by contradiction that there cannot exist uninteresting integers: http://en.wikipedia.org/wiki/Interesting_number_paradox


Yes. All 45,000,000,000 of them. :-)

http://www.youtube.com/watch?v=drE5cHe6c3s


Which domain? Reals? That's a lot of numbers. Infinity, in fact.



Not just an infinity, but a bigger infinity than the integers.


That has always bothered me deeply.

We measure something by comparing its frontiers (where it begins and ends) to something else. If this something has none, this clearly cannot be done.

Of course, it's also clear that between 0 and 1 you have infinite real numbers. But is an infinite inside an infinite enough to provide a size hierarchy?

Maybe the quantum physics guys will prove that the universe is granular in every possible level and that everything is just an enormous pile of huge natural numbers. Then infinity and paradoxes will just be a fun thought experiment, and reality will still be pragmatically ungraspable, but profoundly boring.


Don't be bothered -- this is not actually how it's done.

What you do to compare sizes of sets A and B is, construct a 1:1 function mapping everything in A to something in B and vice versa.

If such a function exists, they're the same cardinality.

It's a little long-winded, but see:

http://en.wikipedia.org/wiki/Cardinal_number

This idea, which seems obvious only in retrospect, is due to Georg Cantor (the guy with the set, and the paradox).


Yeah, but if natural numbers are infinite, than there will always be a natural number to map to a real one, therefore they're the same cardinality.


Strangely enough, this isn't actually true! Ok, so it is true that if you were to go through one by one and label some real numbers with natural number, you would never run out. But the interesting thing comes when you start with the assumption that you have labelled every real number with a natural number. Turns out there's always some left over...

There is a famous proof about this by Georg Cantor: http://en.wikipedia.org/wiki/Cantors_diagonal_argument


It's only a proof if you take a leap of faith and accept certain things. You could argue that that's how math works, but to me the less axioms we need, the better.

I really love this quote from Wittgenstein:

"Where the nonsense starts is with our habit of thinking of a large number as closer to infinity than a small one".

http://en.wikipedia.org/wiki/Controversy_over_Cantor%27s_the...


Which assumptions do you find troubling?


That although both are infinite, there are actually more of one than the other.

That's treating infinite as if it's a limit, when it's not.

If it's uncountable and unmeasurable, than it's non hierarchical.


> That although both are infinite, there are actually more of one than the other.

That's not the assumption, that's the result.


You're right. The assumption would be that there's a countability difference between Naturals and Reals.

That Naturals are infinite but countable and Reals infinite and uncountable.


Thanks for posting this, really enjoyed reading it.


i appreciate posts that anyone can enjoy regardless of their profession


Its all fun and games until you think May 21st is the date the world will end.

More seriously, numbers, and number theory, can be quite interesting and often leads to computational insight in algorithm computation or numerical solving. But ultimately, unless you're a numbers geek, it [ edit: Kaprekar numbers [1] ] doesn't [ don't ] really teach anything.

[1]Sheesh, this place has lost its sense of humor.


Let's say you fancy yourself as a cryptographer. You come up with a black box, it's a function that takes a number and produces another number. You figure you can use it to build a pseudorandom stream of numbers that will be the source of a cipher.

Your algorithm is to start with a random number (the key) and and feed it to your function, producing another number. Which you feed to your function, producing a third number. And so you go, generating a stream of numbers for your cipher.

After reading how Kaprekar's operation leads to a fixed point for four digit numbers and various cycles for other numbers, you might be nudged into investigating to see if there are inputs for your function that lead to cycles and fixed points. Which would pretty-much break your cipher entirely.

Is this interesting? Yes. Is there computational insight? There is for me. Does it teach anything? I dunno, how is teaching something distinguished from providing insight?


A fair point. The process of analyzing Kaprekar numbers could certainly be applied to other numerical sequences.


> Its all fun and games until you think May 21st is the date the world will end.

... what? That has nothing to do with number theory.

> More seriously, numbers, and number theory, can be quite interesting and often leads to computational insight in algorithm computation or numerical solving. But ultimately, unless you're a numbers geek, it doesn't really teach anything.

There are a number [1] [2] [3] [4] of practical uses of number theory that do teach something. I've only listed the simplest uses with respect to cryptography, because those are the ones with which I am familiar, but I assure you, number theory is one of the more applied branches of mathematics.

Granted, some number theory has very few applications. But you won't ever find something practical if you're always asking "Is this practical? I better not look further if it isn't."

[1] http://en.wikipedia.org/wiki/RSA

[2] http://en.wikipedia.org/wiki/Diffie%E2%80%93Hellman_key_exch...

[3] http://en.wikipedia.org/wiki/Digital_Signature_Algorithm

[4] http://en.wikipedia.org/wiki/Elliptic_curve_cryptography


I think you're getting downvoted for conflating gematria ("bible numerics", although it's originally Jewish) and number theory as the word is understood by (recreational) mathematicians. This is not terribly useful, but it's not the kind of crazy that led to the May 21 prediction.


This was my conclusion as well. I didn't know if I should be sad that people thought I didn't know the difference, or that they thought anyone else reading here wouldn't know the difference and so my comment would lead them astray. I've concluded they thought it was 'mean spirited.' (which was not intended of course but the written word, powerful as it is, has limits)

I have always found the 'meme' "Its all fun and games until someone <dubious and improbable action>" amusing. I was trying to come up with a dubious and improbable action which occurred from the mis-application of arithmetic operations on numbers.

What I have learned from this particular exchange is that people who are fans of number theory are sore about 'numerology' perhaps just like astronomers wince at people who conflate astronomy with astrology. Must be watching too much Big Bang Theory lately.


I thought it was more that HN doesn't have a sense of humor--it has a sense of propriety. The HN calculation for the worth of a comment does not assign a negative value to humor, but it does assign a near-zero value.

Thus, a comment which adds no value will be downvoted; a comment which is funny but has significant worth besides its humor will be upvoted.


I've concluded they thought it was 'mean spirited.'

Actually, I thought you were serious, especially given that you went on to criticize number theory as being impractical. I recommend an application of the ;) next time.


I saw that too, since my pronoun 'it' would be inferred to refer back to the noun 'number theory.' Since when I wrote that note I was thinking 'it' referred back to the analysis of Kaprekar numbers, which I didn't think taught much (but see my note about the process being useful in other pursuits). That was why I went back and edited it to illustrate the 'it' I was referring to. Anyway, packets on the far side of the firewall and all that.


here are few more details of this magic number. This article was submitted to HN but didn't get attention. http://ennovates.com/engineering/6174-number/




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: