Created
December 1, 2015 16:46
-
-
Save ksk5280/26056df43041d363ac48 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
0.upto 1000 do |n| | |
phrase = '' | |
if n % 3 == 0 and n % 5 == 0 and n % 7 == 0 | |
puts "SuperFizzBuzz" | |
elsif n % 3 == 0 and n % 7 == 0 | |
puts "SuperFizz" | |
elsif n % 5 == 0 and n % 7 == 0 | |
puts "SuperBuzz" | |
elsif n % 3 == 0 | |
puts "Fizz" | |
elsif n % 5 == 0 | |
puts "Buzz" | |
elsif n % 7 == 0 | |
puts "Super" | |
else | |
puts n | |
end | |
end |
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
0.upto 1000 do |n| | |
phrase = '' | |
phrase += n % 7 == 0 ? 'Super' : '' | |
phrase += n % 3 == 0 ? 'Fizz' : '' | |
phrase += n % 5 == 0 ? 'Buzz' : '' | |
phrase = phrase == '' ? n : phrase | |
puts phrase | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment