Project Euler Problem 004

Statement

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.

Solution

No explanation needed here either:

from CommonFunctions import is_palindrome
 
if __name__ == '__main__':
    result = 0
    n1 = 100
    while n1 < 1000:
        n2 = n1
        while n2 < 1000:
            if is_palindrome(n1 * n2):
                result = max(result, (n1 * n2))
            n2 += 1
        n1 += 1
    print("The result is:", result)

The Python file is available for download here.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License