Skip to content

Instantly share code, notes, and snippets.

@gavinsykes
Created January 16, 2019 20:37
Show Gist options
  • Save gavinsykes/8ebfa6d110cf99dd9c2cbda1d3537667 to your computer and use it in GitHub Desktop.
Save gavinsykes/8ebfa6d110cf99dd9c2cbda1d3537667 to your computer and use it in GitHub Desktop.
# A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 x 99.
#
# Find the largest palindrome made from the product of two 3-digit numbers.
def largest_palindrome_product(n):
result = 0
for i in range(n):
for j in range(n):
if(is_palindrome(i*j) and i*j > result):
result = i*j
return result
def is_palindrome(n):
if(str(n) == str(n)[::-1]):
return True
print largest_palindrome_product(1000) # Returns 906609
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment