The 0x10 problem

Alright. This is a problem that I thought of a couple months ago, and now I’m going to give the answer to it! The problem:

“How many numbers exist such that their decimal representation is the same as their hexadecimal representation?”

If you didn’t understand, it’s fine. It’s asking for the number of numbers that have the same value in decimal and hexadecimal. For example, 152 in decimal is 98 in hexadecimal.

This actually does have a fixed answer, and it’s surprising.

First: the numbers with one hexadecimal digit. There is 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E and F, but A, B, C, D, E and F aren’t decimal digits, so there are ten possible one-digit numbers.

Next! The double digits. Here’s where proof by contradiction may come in. Say that the decimal number is xy, or 10x + y. For hexadecimal, say it is the same value, or xy. In hexadecimal, that’s 16x + y. If they’re the same value, that means 10x + y = 16x + y. Cancel out the y, divide by x on each side, you get 10 = 16.

Let’s go back a step. 10x = 16x. The only way that is possible is if x = 0, which would just be single digits. Therefore, there are no double digit numbers that fit the statement.

Three digits: the new place value in hexadecimal is 256, while in decimal, it is 100. If the new number is abc, that means 100a + 10b + c = 256a + 16b + c. That means 100a + 10b = 256a + 16b, or 156a + 6b = 0. a and b have to be single digits, which means a and b are both 0, defeating the purpose of the triple digits.

It is the same for four-digits numbers and five-digit numbers, but at six digits (in hexadecimal), something interesting happens.

The highest place value is 4^5, which is 1,048,576, which is seven digits, while the hexadecimal representation is 100,000, a six digit number. The decimal becomes a far larger number than the hexadecimal, and we don’t have to go further, since every hexadecimal step is *16.

So what is the final answer?

10. 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9.

It’s funny that this kind of problem could have such a simple answer, but it works.

I had the idea of extending the problem, so that the problem was with octal and decimal. It’s the same concept, with octal being the lower base and decimal being the upper base, so the answer is 8; 0, 1, 2, 3, 4, 5, 6, 7.

If you did it with base 16 and base 20, the answer would be 16, with 0-9 and A-F being the list.

What’s the takeaway here?

Sometimes, start with the simple things, then move on to the complicated things. Maybe not, but it’s true in this case.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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