Created
July 7, 2012 02:43
-
-
Save zschallz/3064019 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
MAX_NUM = 999 | |
MIN_NUM = 100 | |
def is_palindrome?(num) | |
if num.to_s() == num.to_s().reverse | |
true | |
else | |
false | |
end | |
end | |
def find_largest_palindrome() | |
max_found = 0 | |
MAX_NUM.downto(MIN_NUM) { |i| | |
MAX_NUM.downto(MIN_NUM) { |j| | |
if is_palindrome?(i*j) | |
if i*j > max_found | |
max_found = (i*j) | |
end | |
end | |
} | |
} | |
max_found | |
end | |
print find_largest_palindrome.to_s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment