paddockpass/euler_ruby/ex1.rb
2019-02-19 00:48:31 +01:00

6 lines
165 B
Ruby

# Solution for the sum of all number multiple of 3 or 5 between 1 and 999
sum = (1..999).select {|n| n % 5 == 0 || n % 3 == 0}
result = sum.inject(:+)
print result