Skip to content

Instantly share code, notes, and snippets.

@zschallz
Created July 7, 2012 02:43
Show Gist options
  • Save zschallz/3064019 to your computer and use it in GitHub Desktop.
Save zschallz/3064019 to your computer and use it in GitHub Desktop.
Project Euler Problem 4
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