# Distribution of palindromic numbers

We all know what a palindromic number is, it is a number which is the same, independent from which side we read it, for example 101, 202, 33733,....

It is also clear that there are infinity many palindromic numbers. What I am interested in is the frequency of palindromic numbers in specific intervals.

For exmaple: In the interval $[100,999]$ there exist 9 palindromic numbers. In $[1000,9999]$ we have 90, in $[10000,99999]$ we have 252, in $[100000-999999]$ we have 333. I calculated them by hand, is it somehow possible to use mathematica for that?

How does this look like for really high intervals, how does the numbers of palindormic change, what is the relation bewteen the interval and the numbers of palindromic numbers?

What I also asked myself, taking a random palindromic number $a\in[1000,9999]$ for example, how can we reverse the reverse-and-add algorithm. I mean the following: Taking a random number, for exmaple $15$. Then I reverse it and add it to the number itself: $15+51=66$, then we get a palindromic. How can it be evaluated on how many ways the number $66$ can be reiceived? In this case it is obviously one, but how do we know how many different numbers lead for exmaple to the number $5556555$ ?

-

In the interval $[100,999]$ there are $90$ palindromes. You can choose the first digit $9$ ways and the middle digit $10$ ways. Generally, for $n$ digit numbers there are $$\begin {cases} 9\cdot 10^{\frac {n-2}2} & n \text { even} \\ 9\cdot 10^{\frac {n-1}2} & n \text { odd} \end {cases}$$ palindromes. Again, you can choose the first digit $9$ ways and the rest of the first half of the number (rounded up for odd numbers of digits) $10$ ways .

To get $66$ with reverse and add, you can have $15,24,33,42,51$ as starting numbers. For $5556555$ you can certainly have five choices $(1-5)$ for the first digit, six $(0-5)$for the next two, and one choice $(3)$for the middle digit. Then the lower three digits are determined by the top three. This gives $180$ numbers. There might be more, as I have avoided carrying.

-
I believe if you ever have some carrying in the summation, then the resulting number won't be palindromic. Yet to be proven though :) – Dolma Apr 11 '13 at 17:09
You think it is possible to make the following statement: In the interval [a,b] we have a specific number of palindroms, what can we say about the numbers which appear when we reverse the reverse-and-add algorithm. – Babla Apr 11 '13 at 17:10
For exmaple: There are 90 palindromes between 100 and 999. Each of these palindromes can be reiceived reverse-and-add, but what is the number of numbers than can be used to create them, do you know what I mean? – Babla Apr 11 '13 at 17:12
@Babla: for the no-carry approach, you should be able to follow what I did for $5556555$ to find how many numbers there are. For an odd number of digits, the center digit has to be even. Then you take the product of the digits before the middle (one less for the first one to avoid a leading zero) and the lower digits are determined. For an even number of digits you don't have the middle digit problem. – Ross Millikan Apr 11 '13 at 17:16
@RossMillikan: You can actually pick six choices for the second and third digits, it can go all the way from 0 to 5. For example: 3513402 + 2043153 = 5556555 – Dolma Apr 11 '13 at 17:22

The first bit of information you ask about is contained in the statement that $$\text{number of palindromes \le 10^n }=\cases{2(10^{n/2}-1) & n even \\ 11\cdot10^{(n-1)/2}-2 & n odd }$$

(I'll have a think about the reverse-and-add algorithm if you're still interested in that.)

-

Well the number of palindromic numbers there is in an interval $[10^n,10^{n+1}-1]$ is actually the number of palindromic numbers of size $n$.

The answer to the question depends on the parity of $n$. If you denote the number of palindromic numbers of size $n$ by $p_n$ then:

$p_1=10$ and $\forall n\in \mathbb{N}^*, \cases{ p_{2n}=9\times 10^{n-1} \\ p_{2n+1}=10\times p_{2n}=9\times10^n }$

-