Created
February 23, 2012 16:03
-
-
Save uhhuhyeah/1893442 to your computer and use it in GitHub Desktop.
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
(1..100).each do |i| | |
is_multiple_of_3 = i % 3 == 0 | |
is_multiple_of_5 = i % 5 == 0 | |
if is_multiple_of_3 && is_multiple_of_5 | |
puts "Fizzbuzz (#{i})\n" | |
elsif is_multiple_of_3 | |
puts "Fizz (#{i})\n" | |
elsif is_multiple_of_5 | |
puts "Buzz (#{i})\n" | |
end | |
end | |
# Outputs | |
# Fizz (3) | |
# Buzz (5) | |
# Fizz (6) | |
# Fizz (9) | |
# Buzz (10) | |
# Fizz (12) | |
# Fizzbuzz (15) | |
# Fizz (18) | |
# Buzz (20) | |
# Fizz (21) | |
# Fizz (24) | |
# Buzz (25) | |
# Fizz (27) | |
# Fizzbuzz (30) | |
# Fizz (33) | |
# Buzz (35) | |
# Fizz (36) | |
# Fizz (39) | |
# Buzz (40) | |
# Fizz (42) | |
# Fizzbuzz (45) | |
# Fizz (48) | |
# Buzz (50) | |
# Fizz (51) | |
# Fizz (54) | |
# Buzz (55) | |
# Fizz (57) | |
# Fizzbuzz (60) | |
# Fizz (63) | |
# Buzz (65) | |
# Fizz (66) | |
# Fizz (69) | |
# Buzz (70) | |
# Fizz (72) | |
# Fizzbuzz (75) | |
# Fizz (78) | |
# Buzz (80) | |
# Fizz (81) | |
# Fizz (84) | |
# Buzz (85) | |
# Fizz (87) | |
# Fizzbuzz (90) | |
# Fizz (93) | |
# Buzz (95) | |
# Fizz (96) | |
# Fizz (99) | |
# Buzz (100) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment