Number of palindromic numbers less than a power of $10$

194 Views Asked by At

I noticed that every $10^{n}$ there is a certain number of palindromic numbers that I collected in this sequence: $$S=\{a_n,a_{n+1},a_{n+2}...\}=\{10,9,90,90,900,900...\}$$ where every number $a_n$ is the number of palindromic numbers between $10^{n}$ and $10^{n+1}$ starting with $n=0$. Now I wanted to know the number of palindromic numbers less than $10^p$ and I came up with this formula: \begin{cases} 1+\sum^{\lfloor{\frac{p}{2}\rfloor}}_{k=0} 18 \cdot10^k & {\text{if $p$ is even}}\\ 1+\left(\sum^{\lfloor{\frac{p}{2}+1}\rfloor-1}_{k=0} 18 \cdot10^k\right)- \left(9 \cdot 10^{\lfloor{\frac{p}{2}+1}\rfloor-1} \right) & {\text{if $p$ is odd}} \end{cases} Is this right? Thanks! :)

1

There are 1 best solutions below

1
On BEST ANSWER

Your formula almost looks correct, but note the first two terms in your sequence are $10$ and $19$, which are not divisible by $9$, whereas your formula is always divisible by $9$ so your formula isn't quite correct. Also the summation part should be up to $k = \lceil{p/2}\rceil$ instead of $p$.