with the curious property that it is its own square, even though it is obviously not zero or one. We then derived a more efficient algorithm for generating the digits of . Here’s some Haskell code (explained in the previous post) which implements the more efficient algorithm, which I include here just so that this post will be a valid literate Haskell file in its entirety.

To round things out, I’d like to show off some of the cool things we can do with this. First, as we know, it’s possible to do arithmetic with decadic numbers. So let’s implement it!

Addition of decadic numbers is done just like addition of the usual decimal numbers: we add corresponding places (i.e., line up the numbers one under the other and then add in columns).

>plus::Decadic->Decadic->Decadic

First, we have special cases for zero, represented by the empty list of digits: in those cases we just return the other number unchanged.

>plus[]n2=n2>plusn1[]=n1

Next, to add a decadic number whose first digit is x to a decadic number whose first digit is y, we just add x and y and then continue adding recursively.

>plus(x:xs)(y:ys)=(x+y):plusxsys

Of course, we’re not done: this doesn’t do any carrying. Instead of modifying our plus function to do carrying, we just write a function normalize which makes sure every place in a decadic number is between and ; it will come in handy for more than just addition.

>normalize::Decadic->Decadic

The normalize function simply calls a recursive helper function normalize' which keeps track of the current "carry". The starting carry, of course, is zero.

>normalize=normalize'0

To normalize zero (the empty list) when the current carry is zero, just return the empty list.

>wherenormalize'0[]=[]

With a nonzero carry and the empty list, we simply extend the list with a special zero digit and continue normalizing.

>normalize'carry[]=normalize'carry[0]

In the general case, we add the current carry to the next digit x, and compute the quotient and remainder when dividing this sum by ten. The remainder is the next digit d, and the quotient is the new carry which gets passed along recursively.

Well, looks like it’s the same for the first 30 digits at least! We can also compute . Remember, if then , so should be another self-square number. Remember how we thought there might be a self-square number ending in ? Well, this is it!

If you recall, this is in some sense the fundamental reason why the decadic numbers act so funny, because it has zero divisors: pairs of numbers (like and ), neither of which is zero, whose product is nonetheless zero.

I managed to extend this pattern for a few more digits before I got bored. Does it continue forever or does it eventually stop? Is there any deeper mathematical explanation lurking behind this supposed “curiosity”? What’s so special about ? Do patterns like this exist for other functions?

Well, by this point I hope it’s clear that there is indeed a deeper mathematical explanation lurking! The equation

admits the solutions and , but does it admit any other decadic solutions? Notice that given , which has and as solutions, then (and ) are also solutions:

.

So in this case we get

as a solution (the other solution is not a decadic integer).

To implement it, we need a way to halve decadic numbers (I’ll let you work out what’s going on here):

Woohoo! This clearly shows that the pattern does, in fact, continue forever. It also shows us that is not particularly special: any quadratic function that factors as , at the very least, will lead to a pattern like this, and probably lots of other equations do too.

If you’re interested in reading more, here’s where I got some of my information. For example, you can read about how there is another number , defined by starting with and iteratively raising to the fifth power (just as we defined by starting with and successively squaring), such that . It even seems that the author of that page, Gérard Michon, has recently added a discussion of this very problem, prompted by my blog posts! Isn’t the internet great?