Skip to content · ⁨Saltar al contenido⁩

How many halvings? · ⁨¿Cuántas divisiones por dos?⁩

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.

Español

¿Cuántas divisiones entre dos?

n comienza en 40. Divídalo a la mitad con n = n // 2 hasta que alcance 0, contando los pasos en steps.

// divide y descarta el resto, por lo que 5 // 2 es 2. Contar cuántas veces un bucle se ha ejecutado requiere su propia variable, que aumenta en uno cada vuelta.

Log in or create account · ⁨Iniciar sesión o crear cuenta⁩

IGCSE, A-Level & AP