Skip to content

Instantly share code, notes, and snippets.

Created October 8, 2014 22:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/48549ba03babdb1d1acb to your computer and use it in GitHub Desktop.
Save anonymous/48549ba03babdb1d1acb to your computer and use it in GitHub Desktop.
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