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

Count up to five · ⁨5まで数える⁩

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.

日本語

5まで数える

while ループを使って 1 から 5 までを出力し、それぞれ1行ずつ表示します。n は 1 で初期化してください。

増やす計算には n = n + 1 が n - 1 よりも適切で、正しい場所で停止する条件が必要です。n <= 5 は 5 を通過させますが、n < 5 は1つ早く停止させてしまいます。

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

IGCSE, A-Level & AP