-
-
Save devinrhode2/9e6f57e9ead7b0adc214 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
this is mine in the first place ;)