Skip to content

Count up to five · ⁨数到五⁩

English

Count up to five

Use a while loop to print 1 to 5, one per line. Start n at 1.

Counting up needs n = n + 1 instead of n - 1, and a question that stops at the right place. n <= 5 lets 5 through; n < 5 would stop one early.

中文

数到五

用 while 循环打印 1 到 5,每个数一行。让 n 从 1 开始。

往上数要用 n = n + 1 而不是 n - 1,问题也要在正确的地方停下。n <= 5 会让 5 通过;n < 5 会提前一步停下。

Log in or create account · ⁨登录或创建账户⁩

IGCSE, A-Level · ⁨IGCSE、A-Level⁩ & AP · ⁨与 AP⁩