Sum multiples of 3 and 5: Difference between revisions
Content added Content deleted
m (→version 3: added/changed whitespace and comments, used templates for the output sections.) |
(→{{header|Ruby}}: use sum method) |
||
Line 3,452:
Simple Version (Slow):
<lang ruby>def sum35(n)
(1...n).select{|i|i%3==0 or i%5==0}.
end
puts sum35(1000) #=> 233168</lang>
|