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

How many halvings? · ⁨何回半分に分割したか?⁩

English

How many halvings?

n starts at 40. Halve it with n = n // 2 until it reaches 0, counting the steps in steps.

// divides and throws the remainder away, so 5 // 2 is 2. Counting how many times a loop went round needs its own variable, going up by one each turn.

日本語

半分にいくつ回すか?

n は 40 で始まります。n = n // 2 で半分にしながら 0 に達するまで続け、steps にステップ数をカウントしてください。

// は割り算で余りを捨てますので、5 // 2 は 2 となります。ループが何回繰り返されたかを数えるには、各ループで1ずつ増加する独自の変数が必要です。

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

IGCSE, A-Level & AP