Skip to content

Instantly share code, notes, and snippets.

@AlexVPopov
Last active December 21, 2015 22:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexVPopov/6378968 to your computer and use it in GitHub Desktop.
Save AlexVPopov/6378968 to your computer and use it in GitHub Desktop.
Project Euler 4
def palindrome?(a)
a.to_s == a.to_s.reverse
end
def dev_by_3digit?(a)
999.downto(100) do |i|
if a % i == 0 && a / i < 999
return true
end
end
false
end
largest = 999 * 999
while true do
if palindrome?(largest)
if dev_by_3digit?(largest)
break
end
end
largest -= 1
end
puts largest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment