Skip to content

Instantly share code, notes, and snippets.

@pius
Created October 22, 2009 01:22
Show Gist options
  • Save pius/215640 to your computer and use it in GitHub Desktop.
Save pius/215640 to your computer and use it in GitHub Desktop.
#obligatory clever one-liner in response to http://rubyflow.com/items/2904
def sum_of_multiples_of_3_and_5_less_than(limit)
1.upto(limit-1).reject { |x| (x.modulo(3) != 0) and (x.modulo(5) != 0) }.inject(0) {|n,sum| n + sum}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment