How can one count the number of all $n$-digit palindromes? Is there any recurrence for that?
I'm not sure if my reasoning is right, but I thought that:
For $n=1$, we have $10$ such numbers (including $0$).
For $n=2$, we obviously have $9$ possibilities.
For $n=3$, we can choose 'extreme digits' in $9$ ways. Then there are $10$ possibilities for digits in the middle.
For n=4, again we choose extreme digits in $9$ ways and middle digits in $10$ ways
and, so on.
It seems that for even lengths of numbers we have $9 \cdot 10^{\frac{n}{2}-1}$ palindromes and for odd lengths $9 \cdot 10^{n-2}$. But this is certainly not even close to a proper solution of this problem.
How do I proceed?