Counting Binary and Hexadecimal Palindromes

How many nonzero, n-digit, decimal number palindromes are there? These two formulas give the answer:

  • When n is even: 9·10n/2-1
  • When n is odd: 9·10(n+1)/2-1

How many nonzero, decimal number palindromes are there, consisting of n-digits or less? These two formulas give the answer:

  • When n is even: 2(10n/2 – 1)
  • When n is odd: 11·10(n-1)/2 – 2

So for example, there are 900 5-digit decimal palindromes, 9,000 8-digit decimal palindromes, 1,098 decimal palindromes of 5 digits or less, and 19,998 decimal palindromes of 8 digits or less.

In this article, I will derive similar formulas to count binary and hexadecimal number palindromes.

Continue reading “Counting Binary and Hexadecimal Palindromes”

Binary Dates in 2010 and 2011

People have been tweeting about the upcoming dates that look like binary numbers. 10/10/10 seems to be a favorite, both because of its symmetry and because 101010 = 42 in decimal (you know, the answer to the ultimate question of life, the universe, and everything). Here are the nine dates in 2010, interpreted as binary numbers, and with their decimal equivalents:

Continue reading “Binary Dates in 2010 and 2011”

Nines in Quinary

In my article “Nines in Binary”, I proved the following: positive integers of the form 10n-1, that is, integers made up of n digits of 9s, have binary representations with exactly n digits of trailing 1s. Pat Ballew made a clever observation, adapting my result to prove an equivalent statement for base 5 (quinary): positive integers of the form 10n-1 have quinary representations that have exactly n digits of trailing 4s. For example, 9999 in decimal is 304444 in quinary.

In “Nines in Binary”, I derived an expression for 10n – 1 that shows its structure as a binary number:

10n – 1 = (5n – 1) 2n + (2n – 1)

Pat derived a similar expression for 10n – 1 that shows its structure as a quinary number:

10n – 1 = (2n – 1) 5n + (5n – 1)

In essence, he swapped the 2s and 5s, making it the “dual” of my formula, if you will.

I’ll show the details of the derivation and prove why the formula works.

Continue reading “Nines in Quinary”

Finding Numbers That Are Palindromic In Multiple Bases

A palindromic number, or number palindrome, is a number like 74347, which is the same written forward and backward.

A number can be palindromic in any base, not just decimal. For example, 101101 is a palindrome in binary. A number can also be palindromic in more than one base, like decimal 719848917, which is 101010111010000000010111010101 in binary and 5272002725 in octal.

An efficient way to find palindromes in a single base is to generate them, iterating through each integer and constructing palindromes from them. An efficient way to find numbers that are palindromic in multiple bases is to take a palindrome in one base and test if it’s a palindrome in one or more additional bases.

In this article, I’ll show you C code I wrote that finds multi-base numeric palindromes. I used this code to generate tables of numbers that are palindromic in decimal and binary, decimal and hexadecimal, and decimal and octal. I also used this code to solve Euler problem 36, which asks for the sum of all numbers, less than one million, that are palindromic in decimal and binary.

Continue reading “Finding Numbers That Are Palindromic In Multiple Bases”

Nines in Binary

I discovered a cool property of positive integers of the form 10n-1, that is, integers made up of n digits of 9s: they have binary representations that have exactly n digits of trailing 1s. For example, 9,999,999 in decimal is 100110001001011001111111 in binary.

The property is interesting in and of itself, but what is more interesting is the process I went through to discover it. It’s a small-scale example of experimental mathematics: I observed something interesting, experimented to collect more data, developed a hypothesis, and constructed a proof.

Continue reading “Nines in Binary”

How I Taught My Mother Binary Numbers

I introduced my mother to binary numbers a few weeks ago when I showed her my One Hundred Cheerios in Binary poster. It shows the decimal number 100 in binary — 1100100. She’s not an engineer but she’s good with numbers, so I knew she would get it — if only I could find the right way to explain it. Two days ago, I found the right way.

Continue reading “How I Taught My Mother Binary Numbers”

Google is a Binary, Hex, and Octal Number Calculator

Did you know you can use Google as a calculator? Type 1 + 2 + 4 + 8 + 16 + 32 into Google’s search box and you’ll get 63 as the result.

Did you know you can use the calculator with numbers in different bases? It can convert numbers between decimal, binary, hexadecimal, and octal, as well as do arithmetic in those bases. To work in a non-decimal base, just prefix numbers as follows: 0b for binary, for example, 0b1010; 0x for hexadecimal, for example, 0xFF; and 0o for octal, for example, 0o701.

Continue reading “Google is a Binary, Hex, and Octal Number Calculator”

What a Binary Counter Looks and Sounds Like

This is what it sounds like to count from 1 to 255 in binary (music courtesy of Jake Joaquin). It’s so simple, reflecting the simplicity of binary code; yet it speaks volumes about the structure of binary numbers. It inspired me to draw a picture, so I could see what binary counting looks like as well:

Binary counter diagram thumbnail
Visual Interpretation of the Binary Clicker (click image for higher resolution).

Continue reading “What a Binary Counter Looks and Sounds Like”

A Pattern in Powers of Ten and Their Binary Equivalents

In my article “One Hundred Cheerios in Binary”, I made a comment about the decimal number 100, and its binary equivalent, 1100100:

“And will they wonder if the two sub strings of ‘100’ in the binary number have any significance?”

What I meant is if a novice might wonder if a decimal string made up of 1s and 0s must appear in its binary equivalent. Of course that’s not true in general, but it is true for nonnegative powers of ten — the trailing digits of the binary number will match the power of ten!

Continue reading “A Pattern in Powers of Ten and Their Binary Equivalents”

Copyright © 2008-2024 Exploring Binary

Privacy policy

Powered by WordPress

css.php