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 [13]:
def test_if_palindrome(x):
return str(x) == str(x)[::-1]
In [16]:
def test_3digit_products(a):
largest_palindrome = 1
for b in range(a,1,-1):
if b * a <= largest_palindrome:
break
for c in range(a,b-1,-1):
if b * c <= largest_palindrome:
break
if test_if_palindrome(b*c):
largest_palindrome = b*c
return largest_palindrome
In [17]:
print(test_3digit_products(999))
In [ ]:
# This cell will be used for grading, leave it at the end of the notebook.