Project 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.



Before we can being to solved the problem above we first must answer the questions raised by it. In other words:

  • Palindromic Number?


Palindromic Number?

A palindromic number a number that is a palindrome, which is just a word or phrase that is the same in either direction.




def isPalindrome(n):
    return (n==n[::-1])

def findLargestPalindrome():
    largest = 0
    for x in range(100,1000):
        for y in range(100,1000):
            product = x*y

            if product > largest and isPalindrome(str(product)):
                largest = product
    return largest




This method is what is responsible for checking if a number is a palindrome; the “[::-1]” is what takes the parameter and reverses it. That’s it!


Leave a Reply