FizzBuzz with 4 and 6
このページには最新のブラウザ(SharedArrayBuffer対応)が必要です。Chrome、Edge、Firefox、Safariを最新バージョンに更新してください。
これはまだ完了していないレッスンの先にある内容です。まずはそのレッスンを済ませてください:
Python Basics · Counting loops →
4と6のFizzBuzz
罠が含まれたFizzBuzzです。
まずは n % 4 == 0 and n % 6 == 0 で両方の条件をチェックしてください。 2つの数を掛け合わせる n % 24 == 0 は一見近道に見えますが、 12 を見落とすことがあります: ある数が 4 と 6 の両方で割り切れても、必ずしも 24 で割り切れるとは限りません。
難易度 3/5 · 200 コイン + 今日初回達成時の小ボーナス
Print the numbers 1 から 24, one per line, but print Fizz for multiples of 4, Buzz for multiples of 6, and FizzBuzz for numbers that are multiples of both.
実行ボタンをクリックして出力を確認してください。