Skip to content

Instantly share code, notes, and snippets.

@LNA
Last active January 4, 2016 14:49
Show Gist options
  • Save LNA/8636553 to your computer and use it in GitHub Desktop.
Save LNA/8636553 to your computer and use it in GitHub Desktop.
Project Euler Problem 4: Find the largest palindrome made from the product of two 3-digit numbers.
def palindrome
palindromes = []
(999).downto(100).each do |number|
(number ..999).each do |range_of_numbers|
product = number * range_of_numbers
if product.to_s == product.to_s.reverse
palindromes << product
end
end
end
palindromes.max
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment