Created
September 25, 2012 06:05
-
-
Save geopet/3780236 to your computer and use it in GitHub Desktop.
A better ruby fizzbuzz
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
100.times do |i| | |
if i % 5 === 0 and i % 3 === 0 | |
puts 'fizzbuzz' | |
elsif i % 5 === 0 | |
puts 'fizz' | |
elsif i % 3 === 0 | |
puts 'buzz' | |
else | |
puts i | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you want to make sure it is 1-100, use
1.upto(100) do |i|
instead of100.times do |i|