Number of palindromes made of n digits

  • Level: High School 
  • Thread starter Thread starter archaic
  • Start date Start date
Join the discussion
Registration is free. Start your own thread to ask a follow-up.
5 replies · 3K views
archaic
Messages
688
Reaction score
214
Hello! A while I tried to find a formula that allows finding the number of palindromes and I actually came up with something :
So let's say P is the number of palindromes made of n digits,
if n is even then [tex]P = 9 * 10^\frac{n-2}{2}[/tex]
else if n is odd and =/= 1 then [tex]P = 9 * 10^\frac{n-1}{2}[/tex]
This probably exists somewhere on the internet, but who knows ..
See ya!
 
Last edited:
Mathematics news on Phys.org
phinds said:
does it work for n=1 and n=2?
Thanks for your answer, I didn't consider n = 1 ..
It works for n = 2 though, 9 * 100 = 9 (11,22,33,44,55,66,77,88,99).
 
Last edited:
  • Like
Likes   Reactions: Janosh89
Where is the problem with n=1? All 1-digit numbers are trivial palindromes, and the formula gives 9.

There are 9 options for the firs digit (no 0) and 10 options for each following digit up to the center of the number. For even n this means a total of n/2 numbers you are free to choose, for odd n it is (n+1)/2. Taking out the first one, we have (n-2)/2 and (n-1)/2 digits with 10 choices and 1 digit with 9 choices. The rest of the number follows from these choices. And that leads to the formulas in the first post.
Nice observation!
 
mfb said:
Where is the problem with n=1? All 1-digit numbers are trivial palindromes, and the formula gives 9.

There are 9 options for the firs digit (no 0) and 10 options for each following digit up to the center of the number. For even n this means a total of n/2 numbers you are free to choose, for odd n it is (n+1)/2. Taking out the first one, we have (n-2)/2 and (n-1)/2 digits with 10 choices and 1 digit with 9 choices. The rest of the number follows from these choices. And that leads to the formulas in the first post.
Nice observation!
Thank you!
I went to check and actually it states here that 0 is considered a palindrome.
 
  • Like
Likes   Reactions: scottdave
It is a palindrome, but is it a 1-digit number?
A matter of definition I guess.
 
  • Like
Likes   Reactions: Janosh89 and archaic