Last active
November 10, 2020 02:14
-
-
Save Taishikun0721/715990b61fdd0d355e11dd5fa1a00bba to your computer and use it in GitHub Desktop.
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
def fizzbuzz(num) | |
1.step(num) do |n| | |
if n % 15 == 0 | |
puts 'FizzBuzz!' | |
elsif n % 3 == 0 | |
puts 'Fizz!' | |
elsif n % 5 == 0 | |
puts 'Buzz!' | |
else | |
puts n | |
end | |
end | |
end | |
num = ARGV[0].to_i | |
if num == 0 | |
puts '引数の渡し方が正しくありません。' | |
else | |
fizzbuzz(num) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment