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。要数循环转了多少轮,需要一个自己的变量,每轮加一。

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

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