A palindrome is a word or phrase which reads the same forwards and backwards, ignoring spaces and punctuation. Numbers which remain the same when the digits are reversed are also considered to be palindromes. For example \(9\,357\,539\), \(6116\), and \(2\) are all palindromes.
How many positive integers less than \(1\,000\,000\) are palindromes?
We consider cases, based on the number of digits in the palindrome. Since we are looking for positive integers less than \(1\,000\,000\), the minimum number of digits is one and the maximum is six.
Case 1: One-digit palindromes
Each of the integers from \(1\) to \(9\) is a palindrome. Thus, there are \(9\) one-digit palindromes.
Case 2: Two-digit palindromes
In order to be a palindrome, the two digits must be the same. Therefore, the integer must be of the form \(aa\), where \(a\) is an integer from \(1\) to \(9.\) Thus, there are \(9\) two-digit palindromes.
Case 3: Three-digit palindromes
In order to be a palindrome, the first and last digits must be the same. Therefore, the integer must be of the form \(aba\), where \(a\) is an integer from \(1\) to \(9\) and \(b\) is an integer from \(0\) to \(9.\) There are \(9\) choices for \(a\), and for each of these choices there are \(10\) choices for \(b.\) Thus, there are \(9 \times 10 = 90\) three-digit palindromes.
Case 4: Four-digit palindromes
In order to be a palindrome, the first and last digits must be the same, and the second and third digits must be the same. Therefore, the integer must be of the form \(abba\), where \(a\) is an integer from \(1\) to \(9\) and \(b\) is an integer from \(0\) to \(9.\) As with the previous case, there are \(9\) choices for \(a\), and for each of these choices there are \(10\) choices for \(b.\) Thus, there are \(9 \times 10 = 90\) four-digit palindromes.
Case 4: Five-digit palindromes
In order to be a palindrome, the first and last digits must be the same, and the second and fourth digits must be the same. Therefore, the integer must be of the form \(abcba\), where \(a\) is an integer from \(1\) to \(9\) and \(b\) and \(c\) are integers from \(0\) to \(9.\) There are \(9\) choices for \(a\), for each of these choices there are \(10\) choices for \(b\), and for each of these choices there are \(10\) choices for \(c.\) Thus, there are \(9 \times 10 \times 10 = 900\) five-digit palindromes.
Case 4: Six-digit palindromes
In order to be a palindrome, the first and last digits must be the same, the second and fifth digits must be the same, and the third and fourth digits must be the same. Therefore, the integer must be of the form \(abccba\), where \(a\) is an integer from \(1\) to \(9\) and \(b\) and \(c\) are integers from \(0\) to \(9.\) As with the previous case, there are \(9\) choices for \(a\), for each of these choices there are \(10\) choices for \(b\), and for each of these choices there are \(10\) choices for \(c.\) Thus, there are \(9 \times 10 \times 10 = 900\) six-digit palindromes.
Thus, there are \(9+9+90+90+900+900=1998\) palindromes less than \(1\,000\,000.\)