Monday, August 9, 2010

Nerdy Number Corner: 142857 and Other Mathematical Parasites

I can't remember exactly where we were. We might have been on the way to Rocky Point; somewhere like that. In mid-conversation, perhaps even in mid-sentence, I suddenly exclaimed "Oh! Would you look at that?". By now, C is thoroughly familiar with my lack of specifics on certain subjects, but before I realized it, I began to explain. "The odometer... it says 142857... that's, like, one-seventh, one-seventh of a million. But that's not all, if you multiply it by 2, or 3, or 4, or 5, or 6, then the digits cycle around, And there's more..." At that moment, my tirade began to naturally peter off. Audiences to this kind of rant have usually reached the "blank stare" stage long before this point - go to "you're a nerd" look. Go directly to "you're a nerd". Do not pass "smiling sweetly". Do not collect $200. However, C and I already have something of an understanding when it comes to this kind of thing. We both have our intensely nerdy specialties, and mathematics just happens to be mine. For one's partner to take joy that I was excited by such a piece of mathematical trivia; well, that's something new for me.

However, that part is the blessing that comes with having a curious mind; there are several corresponding curses. For instance, when one's mind is evidently filled with such irrelevancies, something else must have been squeezed out along the way. Ah! I'm thick! Look at me, I'm old and thick! Head's too full of stuff! I need a bigger head! I can't help but wonder exactly what of any significance I would be capable of, were I not carrying around all this junk - but, perhaps fortunately for the evolution of our species, that's not how brains work. In fact, the mechanisms are quite opposite. Unlearning something isn't possible. You have to train yourself into new habits, and it is very difficult to get rid of old ones, that still remain there, rendered as synaptic connections, ready to spark at the slightest provocation. This is precisely what happened. Something else about 142857, about that mysterious property, caused a bell to ring in my head; a nagging bell. It wasn't enough to know that one mysterious property; that one that has mystified kids playing with calculators, maybe something they've seen when entering in that famous approximation of pi as 22/7. There was also some puzzle I remembered vaguely, from a long time ago. The curse of it was, although I remembered the connection, I couldn't remember the actual details; and so, I've been carrying a long this thought ever since that car journey. I must stop and work this out. I must stop and work this out.

Right now, then, I'm stopping, and working this out, lest I should drive myself to insanity trying to figure this out. Let's see how it goes.

Let's go back to our magic number 142857. If we take the left-most digit and put it to the right, we get 428571 - which is exactly three times the original number. Likewise, if we take the right-most digit and move it to the left, we get 714285 - which is exactly five times the original number. This is what's been ringing the bells. I see the "rotate left, multiply by 3", and "rotate right, multiply by 5" and I'm thinking, what's so special about 3 and 5? Are these the smallest numbers that make it possible? And, above all, the most loaded of mathematics' questions: why? Maybe we should play with this a bit, and see where it takes us. Perhaps there are numbers which, if we move them to the right, and move the rightmost-digit back around to the left, they get multiplied by any number we want them to?

This, now, gets us into the joy of what it means to be mathematically curious. It's like inventing your own little game to play. We've got a puzzle to solve; we've pretty much created it off the top of our heads, and that gives us the rules of the game. It's up to us how we play. If we give it a go, and the rules are dull and boring, well, maybe we should spice them up a bit. On the other hand, if the rules are too complex and the game is no fun, we need to tweak them in the other direction, until we get something that we can get some entertainment out of. There may be some earth-shattering discovery in there; but, far more likely, it's something we'll do just for fun. We could even write down our puzzle formally now. Let x be an n-digit number whose final digit is k, which becomes q times larger if we move the k from the end of the number to the beginning. At this point, the mathematicians might be tempted to start throwing down equations, and the computer scientists might feel like mounting a brute-force attack on this problem; which, once again, touches on the joy that these kind of sublime puzzles present. The solution is apparently within the grasp of an astute fourth-grader. (I'd love to meet him or her!).

Here's one way how the fourth-grader could solve the problem. Let's solve for the case where moving the digit doubles the number (q=2). Now the last digit that gets moved probably shouldn't be zero; that just doesn't feel right that our number would have a leading zero after moving it; that's not what an n-digit number is. Likewise, the last digit couldn't be a 1, since if after moving it, it's doubled, then before doubling, it would have had a leading zero, too. So let's assume the digit that gets moved is a 2 (k=2). Is this enough to solve the problem, and find n and x? Well, as far as our fourth-grader is concerned, there's a number that looks like "??????2" out there, which is "2??????" once we double it, and the question marks have to be found, we just know they're the same in both cases. What's double "??????2" - well, it ends in a 4. The last question mark is a 4. What's double "????42" - well, it ends in 84, so the next question mark is an 8. You can carry on and reveal the digits, one at a time - when can we stop? Once we get to a number that begins in a 2, right?

It turns out the answer is 105263157894736842 - move the two to the left, and it's precisely double the original number. An 18-digit solution that was found using just elementary arithmetic. Now the mathematical mind has played its game and had it's fun, only one thing remains. Google this answer. Surely, indeed, the only places on the web where such a random-looking 18-digit number could appear would be about this self-same mysterious puzzle? Indeed they are, and the first match is Wikipedia's on this puzzle. Parasitic numbers.

And now I know what they're called, I don't have to have this puzzle bugging me any more! What a peculiar way to reach inner peace.