FizzBuzz with 4 and 6 · 4 和 6 的 FizzBuzz
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · 此页面需较新浏览器(支持 SharedArrayBuffer)。请升级 Chrome、Edge、Firefox 或 Safari 至最新版本。
This one builds on a lesson you haven't finished yet. Do that lesson first: · 此任务基于您尚未完成的课程。请先完成以下课程:
Python Basics · Python 基础 · Counting loops · 计数循环 →
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。把两个数相乘写成 n % 24 == 0 看起来像捷径,却会漏掉 12:一个数可以同时被 4 和 6 整除,却不能被 24 整除。
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. · 打印 1 到 24,每个一行;但 4 的倍数打印 Fizz,6 的倍数打印 Buzz,同时是 4 和 6 的倍数打印 FizzBuzz。
Click Run to see the output here. · 点击“运行”查看此处输出。