Project Euler: Problem 4

https://projecteuler.net/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 [60]:
n = 0                                #Define a variable
for a in range(999, 100, -1):        #gives the range over which we are looking
    for b in range(a, 100, -1):
        x = a * b                    #what we want to do with those numbers
        if x > n:                    #finds the maximum palindrome
            s = str(a * b)
            if s == s[::-1]:
                 n = a * b
print (n)


906609

In [56]:
# This cell will be used for grading, leave it at the end of the notebook.