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 [30]:
def test_palin(x):
    x = str(x)
    prod_flip = []
    n = len(x) - 1
    while n>=0:
        prod_flip.append(x[n])
        n -= 1
    prod_flip = "".join(prod_flip)
    if prod_flip == x:
        return True
    else:
        return False

In [31]:
a = list(range(1, 1000))
b = list(range(1, 1000))
prod_palins = []
for i in a:
    for j in b:
        if test_palin(i*j) == True:
            prod_palins.append(i*j)

In [32]:
max_palindrome_of_3_digit_multiples = prod_palins[len(prod_palins)-1]
print(max_palindrome_of_3_digit_multiples)


90909

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

In [ ]: