且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

欧拉计划之Largest palindrome product

更新时间:2022-08-21 22:43:12

A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 欧拉计划之Largest palindrome product 99.

Find the largest palindrome made from the product of two 3-digit numbers.

def depart(n):
    DList = []
    while n >= 10 :
        DList.append(n % 10)
        n = n/10
    DList.append(n)
    return DList

maxmulti = 10000
for i in xrange(100,1000):
    for j in xrange(100,1000):
        multi = i * j
        MList = depart(multi)
        RList = MList[:]
        RList.reverse()
        if RList == MList:
            if multi > maxmulti:
                maxmulti = multi
                print '{0} * {1}'.format(i,j)

print maxmulti

。。。。。

722 * 968
759 * 953
803 * 909
803 * 959
831 * 968
844 * 957
858 * 966
869 * 982
894 * 957
913 * 993
906609