Skip to content

Instantly share code, notes, and snippets.

@charlesponti
Created May 6, 2013 18:11
Show Gist options
  • Save charlesponti/5526937 to your computer and use it in GitHub Desktop.
Save charlesponti/5526937 to your computer and use it in GitHub Desktop.
Project Euler: Problem 5
def small_multiple(max)
range = *(1..max)
nums = []
results = []
range.each { |i| range.each { |x| nums << i*x } }
nums.each { |i|
range.each { |x|
answers = []
i % x == 0 ? answers << 'true' : answers << 'false'
results << i if !(answers.include? 'false')
}
}
p results.sort.last
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment