Skip to content

Instantly share code, notes, and snippets.

@zschallz
Created July 8, 2012 17:56
Show Gist options
  • Save zschallz/3072048 to your computer and use it in GitHub Desktop.
Save zschallz/3072048 to your computer and use it in GitHub Desktop.
Project Euler Problem 5
# This takes more around 5 minutes to run on a modern i5 machine. Need to optimize.
MIN_NUM = 1
MAX_NUM = 20
def is_consecutively_factorable?(number)
if number == 0 then
return false
end
MAX_NUM.downto(MIN_NUM) { |i|
if number % i != 0
return false
end
}
true
end
i = 0
until is_consecutively_factorable?(i)
i += 1
end
print i
#print is_consecutively_factorable?(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment