Created
October 8, 2014 22:28
-
-
Save anonymous/48549ba03babdb1d1acb to your computer and use it in GitHub Desktop.
This file contains 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
leadingMultiple = 0 | |
multiples = {} | |
# first do multiples of 3: | |
while leadingMultiple < 1000 do | |
multiples[leadingMultiple] = :present; | |
leadingMultiple += 3 | |
end | |
# reset to zero | |
leadingMultiple = 0 | |
# and now do multiples of 5: | |
while leadingMultiple < 1000 do | |
multiples[leadingMultiple] = :present; | |
leadingMultiple += 5 | |
end | |
puts multiples.keys.inject(:+) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment