Skip to content · ⁨コンテンツへスキップ⁩

FizzBuzz with 4 and 6 · ⁨4と6のFizzBuzz⁩

English

FizzBuzz with 4 and 6

A FizzBuzz with a trap in it.

Test for both first, with n % 4 == 0 and n % 6 == 0. Multiplying the two numbers, n % 24 == 0, looks like a shortcut but misses 12: a number can divide by 4 and by 6 without dividing by 24.

日本語

4と6のFizzBuzz

罠が含まれたFizzBuzzです。

まずは n % 4 == 0 and n % 6 == 0 で両方の条件をチェックしてください。 2つの数を掛け合わせる n % 24 == 0 は一見近道に見えますが、 12 を見落とすことがあります: ある数が 4 と 6 の両方で割り切れても、必ずしも 24 で割り切れるとは限りません。

Log in or create account · ⁨ログインまたはアカウント作成⁩

IGCSE, A-Level & AP