Skip to content

Instantly share code, notes, and snippets.

@aarti
Last active December 15, 2015 18:59
Show Gist options
  • Save aarti/5307924 to your computer and use it in GitHub Desktop.
Save aarti/5307924 to your computer and use it in GitHub Desktop.
Find the sum of all the multiples of 3 or 5 below 1000.
total= (1..999).reduce(0) do |sum,n|
n%3 == 0 || n%5 == 0 ? sum + n : sum
end
puts total
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment