euler/ruby/euler001.rb

8 lines
171 B
Ruby
Raw Permalink Normal View History

def multiples_of_three_and_five_below(n)
2014-12-05 00:50:52 +00:00
(3..n-1).select { |i| (i % 3 == 0) || (i % 5 == 0) }
end
2014-12-05 00:50:52 +00:00
def solution
multiples_of_three_and_five_below(1000).inject(:+)
end