Sum multiples of 3 and 5: Difference between revisions

Content added Content deleted
(→‎{{header|Python}}: Pylinted for Python 3, updated output)
Line 752: Line 752:
.select { |i| i % 3 == 0 || i % 5 == 0 }
.select { |i| i % 3 == 0 || i % 5 == 0 }
.reduce { |acc, i| acc + i }
.reduce { |acc, i| acc + i }
end

also

def sum_3_5_muliples(n)
(0...n).select { |i| i % 3 == 0 || i % 5 == 0 }.sum
end
end


puts sum_3_5_muliples(1000)
puts sum_3_5_muliples(1000)
# => 233168
</lang>
</lang>
{{out}}
<pre>
233168
</pre>


=={{header|D}}==
=={{header|D}}==