Skip to content

Instantly share code, notes, and snippets.

@aptinio
Created November 4, 2009 06:35
Show Gist options
  • Save aptinio/225866 to your computer and use it in GitHub Desktop.
Save aptinio/225866 to your computer and use it in GitHub Desktop.
Project Euler Problem 4
def palindrome?(integer)
string = integer.to_s
string == string.reverse
end
products = []
999.step(100, -1).to_a.each do |a|
999.step(100, -1).to_a.each do |b|
product = a*b
products << a*b if palindrome?(product)
end
end
products.max
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment