-
-
Save d0ppler/bff8aa420749b168ea4d 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
# 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