Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions 01.fizzbuzz/fizzbuzz.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
def fizzbuzz(n)
(1..n).each do |i|
if i % 3 == 0 && i % 5 == 0
puts "FizzBuzz"
elsif i % 3 == 0
puts "Fizz"
elsif i % 5 == 0
puts "Buzz"
else
puts i
end
end
end

fizzbuzz(20)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ファイルの末尾に改行がないようです。次からでいいので、改行がはいるようにしましょう。エディタやIDEの設定で自動的にはいるように設定できるので、試してみてください。
参考: https://gist.github.com/OleksiyRudenko/d51388345ea55767b7672307fe35adf3