欧拉计划---0004 Largest palindrome product(找出由两个三位数乘积构成的最大回文)

第四题原文如下:

Largest palindrome product

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.

翻译过后如下:

找出由两个三位数乘积构成的最大回文

一个回文数指的是从左向右和从右向左读都一样的数字。最大的由两个两位数乘积构成的回文数是9009 = 91 * 99.

找出最大的有由个三位数乘积构成的回文数。

python代码:

def FoundMaxPalindrome():
    max = 0
    for x in xrange(999, 100, -1):
        for y in xrange(999, 100, -1):
            if isPalindrome(str(x*y)):
                if max < x*y:
                    max = x*y
                    print x, y ,max
    print max

猜你喜欢

转载自blog.csdn.net/zd199218/article/details/43605795
今日推荐