#4: Largest palindrome product | Ben Cunningham

# #4: Largest palindrome product

Problem by Project Euler · on November 16, 2001

A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is $9009 = 91 \times 99$.

Find the largest palindrome made from the product of two 3-digit numbers.

# Python

def is_palindrome(x):
if str(x) == str(x)[::-1]:
return True
return False

digits = 3
ans = 0

for m in range(10 ** (digits - 1), 10 ** digits):
for n in range(m, 10 ** digits):
x = m * n
if (x > ans) and (is_palindrome(x)):
ans = x

print(ans)

## 906609