Created
October 22, 2009 01:22
-
-
Save pius/215640 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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