Created
November 25, 2012 02:52
-
-
Save edalorzo/4142197 to your computer and use it in GitHub Desktop.
Project Euler-Problem #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_palindrome(n): | |
text = str(n) | |
return text == text[::-1] | |
def palindromes(): | |
for j in range(100,1000): | |
for k in range(100,1000): | |
product = j * k | |
if is_palindrome(product): | |
yield product | |
if __name__ == '__main__': | |
print "The largest palindrome made from the product of two 3-digit numbers is %d" % max(palindromes()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment