euler/euler001.rb

10 lines
213 B
Ruby
Raw Normal View History

def multiples_of_three_and_five_below(n)
multiples = []
(3..n-1).each do |i|
multiples << i if ((i % 3 == 0) || (i % 5 == 0))
end
multiples
end
puts multiples_of_three_and_five_below(1000).inject(:+)