Created
March 25, 2012 08:53
-
-
Save johana-star/2192466 to your computer and use it in GitHub Desktop.
FizzBuzz in Ruby (revised
This file contains hidden or 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
(0..100).each do |number| | |
case | |
when number % 3 == 0 then puts "Fizz" + ("Buzz" if number % 5 == 0).to_s | |
when number % 5 == 0 then puts "Buzz" | |
else puts number | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Seems clever, but this complication is not as readable, slower, and more likely to break with editing.