FizzBuzz with 4 and 6
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version.
This one builds on a lesson you haven't finished yet. Do that lesson first:
Python Basics · Counting loops →
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.
Difficulty 3/5 · 200 coins + a small bonus on first completion today
Print the numbers 1 to 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.
Click Run to see the output here.