Skip to content

Instantly share code, notes, and snippets.

@leeacto
Last active December 19, 2015 03:29
Show Gist options
  • Select an option

  • Save leeacto/5890897 to your computer and use it in GitHub Desktop.

Select an option

Save leeacto/5890897 to your computer and use it in GitHub Desktop.
st = Time.new
top = 999*999
found = false
pal = true
until found == true do
#check if palindrome
tops = top.to_s
if tops != tops.reverse
pal = false
else
pal = true
end
if pal == true
a = 101
b = 101
while a <= 999 && found == false
b = 101
while b <= 999 && found == false
if a * b == top
found = true
else
b += 1
end
end
if found == false
a += 1
end
end
end
if found == false
top -= 1
pal = false
end
end
puts a
puts b
en = Time.new - st
puts en
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment