how many n-digit palindromes exist

4k Views Asked by At

I'd never seen this kind problem before, and don't know where to start. Any help is appreciated. Thank you very much!

A palindrome is a number that is the same forwards and backwards. For example, $212$ and $21466412$ are palindromes. Consider an arbitrary palindrome with n digits where n is even. Find a formula, in terms of $n$, of how many $n$-digit palindromes exist. All equivalent answers will be accepted.

2

There are 2 best solutions below

0
On

Since you're given that $n$ is even, simply think of it as a sequence of $\frac n2$ digits that's mirrored to give the latter half.

The number of such unique $\frac n2$ left-most digit sequences is found by considering that the first digit has $9$ possibilities ($1$ to $9$ inclusive) and the rest have $10$ each ($0$ to $9$ inclusive).

So the number of possibilities is $9 \times 10^{\frac n2 - 1} = (0.9)10^{\frac n2}$

0
On

This is easier than it looks at first. Consider the first $n/2$ digits of the number: That is some number between $100\ldots 0$ and $999\ldots 9$. There are $9\cdot 10^{\frac{n}{2}-1}$ such numbers.

And each of those numbers can be used to create a palindromic number merely by writing the next $n/2$ digits as that number written backward! All palindromes of even length are formed that way. So the answer is there are

$$9\cdot 10^{\frac{n}{2}-1}$$

distinct $n$-digit palindromes if $n$ is even.