Skip to content

Instantly share code, notes, and snippets.

@devinrhode2
Forked from anonymous/ProjectEuler.1.rb
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devinrhode2/9e6f57e9ead7b0adc214 to your computer and use it in GitHub Desktop.
Save devinrhode2/9e6f57e9ead7b0adc214 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(:+)
@devinrhode2
Copy link
Author

this is mine in the first place ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment