## Monday, May 13, 2013

### On palindromic numbers, part two

In my last post on palindromic numbers, I looked at the frequencies of valid & invalid palindromic numbers and found that almost all invalid palindromes are odd. To explore why this might be, I'll now look at the differences between even and odd palindromes. (By this I mean even and odd numbers, $$n$$, that have palindromic representations in a base less than $$n - 1$$.)

### Of evens and odds

Of the 4997 valid even palindromes through 10,000, over 62% have a length of 3 digits and just under 20% have a length of 2 digits. Palindromes of lengths ranging from 4 to 9 comprise the nearly 18% remaining. This is somewhat similar to the odds: just over 70% have length 3, a little less than 14% have length 2, and the bit more than 16% remaining have lengths ranging from 4 to 14. So the odds are spread out a bit more as far as lengths go, but they and the evens are fairly similar in that regard.

What about the frequency of bases? Do the evens have more or less of certain bases or ranges of bases? Well, as far as number of bases, the evens have a slightly higher (a little over 5.5%) diversity of (valid, lowest) bases over the first 10,000 counting numbers. I don't think that's enough to be significant, though (I'd love to be proven wrong in the comments!), so let's look at the frequencies of individual bases:

Now here's where it gets fascinating. For the lower bases, the evens have much more odd bases and the odds have much more even bases. (Why do evens have no base-2 palindromes? A binary palindrome would have to end in a '1' — allowing leading zeroes would cause all sorts of problems — and binary numbers that end in '1' are odd.) In general, the larger the base, the lower the frequency, but around base-20, both the evens and odds see an upswing in frequencies of all bases that gradually tapers down to about base-50. It's here that we see a recurrence of the original pattern, albeit at a much smaller scale. (There is also a small uptick at base-28 for both evens and odds, and the high/low pattern makes a brief appearance in the early thirties.)

### Can you take me higher?

Obviously, this particular patterning is the result of the limited number set we're working with. Does it continue for larger number groups?

It seems so. (With one order-of-magnitude increase, at least.)

More pointedly, the early alternating pattern continues, as does the overall swelling later and the return to the alternating pattern. But— there are some hiccups in the alternating pattern now, the swelling occurs later (and is now responsible for the highest frequencies), and the later alternation is less pronounced.

I won't check higher numbers because it takes quite some time to compute these numbers (at least with the quick script I wrote for the task, and I don't wish to spend the time to see if I can make a faster program). However, if the trends I see continue, it looks like the alternating pattern becomes most significant as the upper number limit approaches infinity. (I base this on the alternations continuing mostly unhindered and the swelling moving into higher ranges. As we approach an infinite upper bound, it would follow that the swelling would approach infinity as well.) So why are even numbers likely to have their lowest-base palindrome be in an odd base and vice-versa for the odds?

I don't have an answer to that question. I'd be interested if any readers did. In the meantime, I'll look at something I noticed about one of my first lists: the invalid palindromes. For a refresher, let's look at those, this time through 10,000:

• 1
• 2
• 3
• 4
• 6
• 11
• 19
• 47
• 53
• 79
• 103
• 137
• 139
• 149
• 163
• 167
• 179
• 223
• 263
• 269
• 283
• 293
• 311
• 317
• 347
• 359
• 367
• 389
• 439
• 491
• 563
• 569
• 593
• 607
• 659
• 739
• 827
• 853
• 877
• 977
• 983
• 997
• 1019
• 1049
• 1061
• 1187
• 1213
• 1237
• 1367
• 1433
• 1439
• 1447
• 1459
• 1511
• 1553
• 1579
• 1669
• 1709
• 1753
• 1759
• 1907
• 1949
• 1993
• 1997
• 2011
• 2063
• 2087
• 2099
• 2111
• 2137
• 2179
• 2207
• 2287
• 2309
• 2339
• 2417
• 2459
• 2503
• 2657
• 2677
• 2683
• 2693
• 2713
• 2749
• 2897
• 2963
• 3023
• 3089
• 3119
• 3229
• 3253
• 3259
• 3323
• 3371
• 3407
• 3449
• 3547
• 3559
• 3583
• 3623
• 3643
• 3833
• 3847
• 4007
• 4073
• 4091
• 4099
• 4139
• 4157
• 4211
• 4283
• 4337
• 4339
• 4349
• 4391
• 4463
• 4523
• 4549
• 4643
• 4679
• 4729
• 4787
• 4871
• 4909
• 4919
• 4933
• 5011
• 5021
• 5039
• 5059
• 5099
• 5179
• 5231
• 5297
• 5303
• 5309
• 5351
• 5387
• 5417
• 5431
• 5471
• 5503
• 5527
• 5653
• 5693
• 5711
• 5791
• 5827
• 5839
• 5939
• 6047
• 6067
• 6079
• 6089
• 6131
• 6199
• 6229
• 6247
• 6269
• 6277
• 6311
• 6343
• 6359
• 6389
• 6551
• 6599
• 6653
• 6793
• 6871
• 6947
• 6983
• 6991
• 7019
• 7079
• 7159
• 7213
• 7247
• 7283
• 7433
• 7487
• 7691
• 7817
• 7877
• 7949
• 7963
• 8017
• 8069
• 8089
• 8123
• 8147
• 8221
• 8243
• 8287
• 8291
• 8293
• 8423
• 8539
• 8573
• 8669
• 8699
• 8783
• 8863
• 8941
• 9043
• 9059
• 9067
• 9173
• 9209
• 9227
• 9277
• 9337
• 9341
• 9377
• 9419
• 9421
• 9533
• 9587
• 9643
• 9689
• 9739
• 9781
• 9887

I've highlighted the non-prime numbers. There are only three: 1, 4 and 6. Aha! So, not only are all invalid palindromes above 6 odd, they are all prime as well! (Assuming this continues beyond 10,000. I have no proof it does, but so far it works.)