Skip to content

Instantly share code, notes, and snippets.

@d0ppler
Created April 22, 2015 15:05
Show Gist options
  • Save d0ppler/bff8aa420749b168ea4d to your computer and use it in GitHub Desktop.
Save d0ppler/bff8aa420749b168ea4d to your computer and use it in GitHub Desktop.
# first example
(1..100).each{|i|
x = ''
x += 'Fizz' if i%3==0
x += 'Buzz' if i%5==0
puts(x.empty? ? i : x)
# second example
1.upto(100) do |i|
x, y = i%3, i%5
print "Fizz" if x == 0
print "Buzz" if y == 0
print i if x!= 0 && y!= 0
puts
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment