Euler Problem 4

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.


In [1]:
def is_palindrome(n):
    s = str(n)
    return s == s[::-1]

largest = 0
for m in range(999, 99, -1):
    if m*999 < largest:
        break
    for n in range(1000, m-1, -1):
        product = m*n
        if is_palindrome(product) and product > largest:
            largest = product
            break
print(largest)


906609

In [ ]: