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 [2]:
big = 0

# loop through all 3-digit numbers for first value defined as q
for q in range (100, 999):
    #loop through all 3-digit numbers for secon value defined as s
    for p in range(100, 999):
        #multiply q and p and define it as s and turn it in to a string
        s = str(q * p)
        # reverse the string s and define the reverse as t
        t = s[::-1]
        #loop through all s and t and for those that are equal turn the string in to an intager called s
        while s == t:
            s = int(s)
            #loop throug all s from the previous loop and return the largest in an intager called big
            while s > big:
                big = s

#print largest value
print (big)


906609

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