Can every number be written as a palindrome in some base?

My muse, Bartholomew, visited me this weekend with a question:

Can every number be written as a palindrome in some base?

What’s that mean!?

Okay – first thing’s first. A palindrome is something that can be written the same way forward as backward. Like mom or 1001. Typically we ignore punctuation, so things like, “Go hang a salami, I’m a lasagna hog,” also count as a palindrome.

And base means the number system – in our normal word we use base 10. Computers use base 2 (all ones and zeros) and hexadecimal (like the color codes you sometimes see on a computer – hex#ff9900 is the MathFour orange).

Notice in hexadecimal – using 16 digits – we have to use letters as numbers. I did a video on base 12 arithmetic here – base 12 also uses some letters as numbers.

So what’s the question again?

Take any number – say 85. Can you convert it to some other base (like base 2 or base 7 or base 61) so that it looks like a palindrome?

You can work hard converting numbers – or you can have a spreadsheet or Wolfram Alpha do it for you.

If you use Wolfram Alpha, put in the statement “convert NUMBER base 10 to base NEW_BASE” – change the blue things, but leave the black ones the same.

Notice if you convert 85 base 10 to base 84, the result is 1184 – which means every number can be written as a palindrome in the base that is one less than it.

So 27810 is 11277. And 11 is a palindrome!

So yes – every number can be written as a palindrome in some base.

That’s a lame answer!

You’re right. That’s what mathematicians call a “trivial” solution. It’s true, but it’s pretty lame.

So let’s rewrite the question to be more interesting.

Can every number be written as a palindrome in a base less than or equal to 10?

This lets us use our “normal” digits – and it makes it more natural.

I put together a spreadsheet to calculate some conversions. The yellow highlights are palindromes. The blue rows – those have no palindromes!

Not every number can be written as a palindrome!

That answers the question – but any good mathematician will ask the next question:

What’s up with the numbers that can’t be written as palindromes?

I did up to 100 and these numbers didn’t have palindrome conversions:

19
25, 29
39
47
53, 58, 59
69
75, 76, 79
84, 87
90, 94, 95, 96

Some are primes, some not. One’s even a perfect square!

I leave the question with you…

Any thoughts? What happens if you change the question again? Can you ask your children this question?

Share in the comments – and don’t forget to tweet it!

then
or
You might also like:



This post may contain affiliate links. When you use them, you support us so we can continue to provide free content!

5 Responses to Can every number be written as a palindrome in some base?

  1. Zero-thly, great post. Anything that gets me thinking (and working, as you’ll soon find out) so hard is a welcome addition to my day.

    Firstly, you missed a few palindromes. 25, 29 and 59 are all base-4 palindromes (121, 131 and 323, respectively).

    On a lengthier and more interesting note, I think the limit of base-10-or-less palindromes is too arbitrary. Yes, it’s easier to look & think about for us humans who’re used to base-10 numbers, but where’s the fun there?

    I tend more towards general solutions to problems, so I think a more interesting question is: What is the lowest base in which n is a palindrome? (Obviously, we’re omiting base-1 numbers as they are all palindromes.)

    Also, since all numbers are palindromes in bases greater than n-1, why not limit “valid” palindromes to those less than n-1? So the question becomes: Does n have a palindrome in a base less than base-n-minus-one? Is there a pattern to these numbers? Do they occur more, less or equally frequent as we look at larger sets of integers?

    Of course, computers make these things so much easier to look at. I made a quick Python script to examine palidromic numbers. The benefits here are I don’t have to worry about inventing a character for each digit. I can just leave the decimal value of that digit as-is and place the digits in a list. So, here are some results for integers 1-100:

    First, the full list:
    n base palindrome
    1 2 [1]
    2 3 [2]
    3 2 [1, 1]
    4 3 [1, 1]
    5 2 [1, 0, 1]
    6 5 [1, 1]
    7 2 [1, 1, 1]
    8 3 [2, 2]
    9 2 [1, 0, 0, 1]
    10 3 [1, 0, 1]
    11 10 [1, 1]
    12 5 [2, 2]
    13 3 [1, 1, 1]
    14 6 [2, 2]
    15 2 [1, 1, 1, 1]
    16 3 [1, 2, 1]
    17 2 [1, 0, 0, 0, 1]
    18 5 [3, 3]
    19 18 [1, 1]
    20 3 [2, 0, 2]
    21 2 [1, 0, 1, 0, 1]
    22 10 [2, 2]
    23 3 [2, 1, 2]
    24 5 [4, 4]
    25 4 [1, 2, 1]
    26 3 [2, 2, 2]
    27 2 [1, 1, 0, 1, 1]
    28 3 [1, 0, 0, 1]
    29 4 [1, 3, 1]
    30 9 [3, 3]
    31 2 [1, 1, 1, 1, 1]
    32 7 [4, 4]
    33 2 [1, 0, 0, 0, 0, 1]
    34 4 [2, 0, 2]
    35 6 [5, 5]
    36 5 [1, 2, 1]
    37 6 [1, 0, 1]
    38 4 [2, 1, 2]
    39 12 [3, 3]
    40 3 [1, 1, 1, 1]
    41 5 [1, 3, 1]
    42 4 [2, 2, 2]
    43 6 [1, 1, 1]
    44 10 [4, 4]
    45 2 [1, 0, 1, 1, 0, 1]
    46 4 [2, 3, 2]
    47 46 [1, 1]
    48 7 [6, 6]
    49 6 [1, 2, 1]
    50 7 [1, 0, 1]
    51 2 [1, 1, 0, 0, 1, 1]
    52 3 [1, 2, 2, 1]
    53 52 [1, 1]
    54 8 [6, 6]
    55 4 [3, 1, 3]
    56 3 [2, 0, 0, 2]
    57 5 [2, 1, 2]
    58 28 [2, 2]
    59 4 [3, 2, 3]
    60 9 [6, 6]
    61 6 [1, 4, 1]
    62 5 [2, 2, 2]
    63 2 [1, 1, 1, 1, 1, 1]
    64 7 [1, 2, 1]
    65 2 [1, 0, 0, 0, 0, 0, 1]
    66 10 [6, 6]
    67 5 [2, 3, 2]
    68 3 [2, 1, 1, 2]
    69 22 [3, 3]
    70 9 [7, 7]
    71 7 [1, 3, 1]
    72 5 [2, 4, 2]
    73 2 [1, 0, 0, 1, 0, 0, 1]
    74 6 [2, 0, 2]
    75 14 [5, 5]
    76 18 [4, 4]
    77 10 [7, 7]
    78 5 [3, 0, 3]
    79 78 [1, 1]
    80 3 [2, 2, 2, 2]
    81 8 [1, 2, 1]
    82 3 [1, 0, 0, 0, 1]
    83 5 [3, 1, 3]
    84 11 [7, 7]
    85 2 [1, 0, 1, 0, 1, 0, 1]
    86 6 [2, 2, 2]
    87 28 [3, 3]
    88 5 [3, 2, 3]
    89 8 [1, 3, 1]
    90 14 [6, 6]
    91 3 [1, 0, 1, 0, 1]
    92 6 [2, 3, 2]
    93 2 [1, 0, 1, 1, 1, 0, 1]
    94 46 [2, 2]
    95 18 [5, 5]
    96 11 [8, 8]
    97 8 [1, 4, 1]
    98 5 [3, 4, 3]
    99 2 [1, 1, 0, 0, 0, 1, 1]
    100 3 [1, 0, 2, 0, 1]

    Now, “invalid” palindromes (lowest base == n – 1) [note how few there are]:
    3 2 [1, 1]
    4 3 [1, 1]
    6 5 [1, 1]
    11 10 [1, 1]
    19 18 [1, 1]
    47 46 [1, 1]
    53 52 [1, 1]
    79 78 [1, 1]

    And, just because, those invalid based on the orginal standards in the post (base > 10):
    19 18 [1, 1]
    39 12 [3, 3]
    47 46 [1, 1]
    53 52 [1, 1]
    58 28 [2, 2]
    69 22 [3, 3]
    75 14 [5, 5]
    76 18 [4, 4]
    79 78 [1, 1]
    84 11 [7, 7]
    87 28 [3, 3]
    90 14 [6, 6]
    94 46 [2, 2]
    95 18 [5, 5]
    96 11 [8, 8]

    Interestingly, no number through 100 uses a digit greater than 8 in their palindromic representation. In fact . . . . . . the first number to use 10 (or greater) in their lowest-base palindromic representation is 120 (base 11, [10, 10]). (108 is the first to use 9.)

    I haven’t looked at frequencies yet, but that’ll be the next thing to look at. (Oh, and though 25 does have a base-10-or-less palindrome, many squares do not, 361 being the first.)

    • This is such an impressive comment I’m likely to reprint it as a post! Thanks so much for taking the time to share your thoughts and work!

  2. I had the same idea! Plus some expansion & pretty graphs, much of which will be in one or more follow-up posts, depending on how many ideas I get for exploring this. (The more I write on it, the more ideas I seem to have.)

    But feel free to do your own post as well, I’m sure you’ll get more exposure than my fledgling blog.

Leave a reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.