# 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·10
^{n/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(10
^{n/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.