Palindromes are numbers which are equal to their reverse. For example-
1 2 1 = 1 2 1
Calculate
n ∑ ∞ n 1
where n is a palindrome in base 10.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
This has to be a CS problem, I think because this is a fact found with the help of programming.
Log in to reply
Updated to CS
Trying from 4-5 days at last gave off , can't do without computer science - I don't know anything about it
Log in to reply
That is the point exactly! School Education imparts the illussion in the students that every problem in the real world looks like a textbook problem and can be solved with analytical methods.
Log in to reply
@Agnishom Chattopadhyay – I agree with you! It is so damn true.
@Agnishom Chattopadhyay – I am extremely sorry! I won't post any problems like these. Sorry :(
Log in to reply
@Vatsalya Tandon – Please do not be sorry. I'm glad that you posted this problem. Post more of these! :)
I was not criticising you, I was criticising the school system which is throwing us into the darkness.
good coding..........
Shouldn't it be infinity. It contains the harmonic series \sum_{n=1}^inf = inf ?
Log in to reply
It is very much a convergent series. Because of the very high rate of growth of the denominator, I would suppose.
http://en.wikipedia.org/wiki/Palindromic number#Sum of the reciprocals
We can show convergence pretty quickly.
Consider the 2 k + 1 digit numbers. The number of palindromes is 1 0 k + 1 . Each reciprocal is bounded above by 1 0 2 k 1 ,hence their sum is bounded above by 1 0 k − 1 1 . Hence, the sum of all reciprocals of palindromes with odd number of digits, is 1 − 1 0 1 1 0 = 9 1 0 0 . Similarly, for the 2 k digit numbers, the number of palindromes is 1 0 k , and each reciprocal is bounded above by 1 0 2 k − 1 1 . Hence their sum is bounded above by 1 0 k − 1 1 . Hence, the sum of all reciprocals of palindromes with even number of digits is 1 − 1 0 1 1 = 9 1 0 .
Hence, the sum is finite.
Python:
1 2 3 4 5 6 7 8 |
|
Did you learn Python at school ?
Log in to reply
No, @Azhaghu Roopesh M I learned it 3 weeks ago ,with the help of sir, @Chew-Seong Cheong .And still i'm am not perfect
1 2 3 4 5 |
|
OMG Java code is smaller than Python!
Is that so:
1 |
|
No. It's not. Less line doesn't make it smaller. Anyway, great job with the code.
sum=0.0
for x in range(1,10):
#print(x)
sum += 1.0 / x
print(sum)
xsum=sum
for max in [100,1000,10000,1000000]:
sum=xsum
for o in (0,1):
for i in range(1,max):
if o == 0:
eii = 1
else:
eii = 10
for ii in range(0,eii):
x=str(i)
y=x[::-1]
if o == 1:
m = str(ii)
else:
m = ""
z=x+m + y
#print(o,i,ii," ",z)
sum += (1.0 / int(z))
print(sum)
Problem Loading...
Note Loading...
Set Loading...