#! /usr/bin/env python3 """ pe4.py https://mind.kittttttan.info/py/pe4 """ # https://mind.kittttttan.info/py/pe0 from pe import is_palindrome def pe4(n=3): """ Find the largest palindrome made from the product of two 3-digit numbers. """ first, last = 9*10**(n - 1) + 1, 10**n max = 0 for x in range(first, last): for y in range(x, last): xy = x * y if xy > max and is_palindrome(xy): max = xy print(max) if __name__ == "__main__": pe4()