everyhting gone over my head
What is the 10000th palindrome?
PS: 131, 1441, 1020201 etc are palindromes...
which are the same from both sides :)
-
UP 0 DOWN 0 1 18
18 Answers
I cant stand seeing this one unsolved... [2]
I have to give the solution now...
Let us see the number of 1 digit palindromes : 9
Number of 2 digit palindromes : 9
Number of 3 digit palindromes : 9 x 10 = 90
Number of 4 digit Palindromes : 90
Number of 5 digit Palindromes: 900
Number of 6 digit Palindromes: 900
Number of 7 digit Palindromes: 9000
So what is obvious is that it will be a 7 digit number..
Now what is not obvious is how to go about from here...
Let us revisit the palindromes...
If I fix the first digit, the last digit also gets fixed...
So what is the number of 7 digit palindromes with 1st digit as 1? (10^3=1000)
Number of palindromes with < 7 digits = 1998
So we have to find the 10000-1998 = 8002 th palindrome...
So we have 1000 7 digit palindromes starting with 1, 2, ... 8, 9
we need to find the 8002th
which means that we have to find the 2nd 7 digit palindrome starting with 9
The smallest such palindrome would be 9000009
By simple observation, you can say that the 2nd smallest such palindrome would be 9001009
[1]
bhargav.. this is not that simple..
I had a reccursion in my mind that the nth palindrome of m digits will be very closely related to the palindromes of m-1 digit..
as is suggested by the solution that i have given..
but the problem was how to relate those..
http://eric-schmidt.com/eric/palindrome/index.html
I stopped thinking after seeingthis paper (given by anant sir) and happens to be the 1st search result on nth palindrome :)
the only hard thing
is distinguishing between palindromes with an even and odd number of digits
finding the nth palindrome with an even number of digits is easy; it's just n, and then n reversed
similarly finding the nth palindrome with an odd number of digits is easynow you have to count how many of each digit there are in order to determine where the nth palindrome is
it's a tedious calculation
You have asked me this .. and we know how difficult this one is :D [1]
I could not dare to read 2 pages of those expressions :D
The 10000th palindrome is 9001009. I have assumed 1 as the first palindrome and an ascending order arrangement for the palindromic numbers.
lol..
The problem is that if i give a hint.. it will give the whole solution :(
Can you tHink of some recurrsion
sir cant get that elephant hint..............
i just know one thing that it will lie b/w 106 and 107 ...but how to take it further ??
no one seems to be interested :(
even when i thought this was easier than most other QOD's that I have given!!
lol.. there is no need of a program.. you just have to find a small clue..
I will give a hint to begin with
there are 9 palindromes of 1 digit...
Now can you take it further?
can make a simple C program to do thatif tired of doing mentally[3]
I guess you should try this a bit more..??
[1]
Hint: This works more like the question where you ahve to find the position of Elephant among all words that can be made by the letters in Elephant..