标签:
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
Find the largest palindrome made from the product of two 3-digit numbers.
python code:
import math
sqrt=math.sqrt
def func1(x):
s=str(x)
n=int(len(s)/2)
for i in range(0,n):
if s[i]!=s[-(i+1)]:
return 0
return 1
def func2(x):
for i in range(100,1000):
if x%i==0:
if x/i<1000:
print(i)
return 1
return 0
for i in range(10000,1000000)[::-1]:
if func1(i)==1:
if func2(i)==1:
print(i)
break
result : 906609
time : 1s
标签:
原文地址:http://blog.csdn.net/zhangzhengyi03539/article/details/43160377