How many halvings? · ¿Cuántas divisiones por dos?
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.
¿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.
n starts at 40. Halve it with n = n // 2 until it reaches 0, counting the steps in steps. · n comienza en 40. Divídalo entre 2 con n = n // 2 hasta que alcance 0, contando los pasos en steps.
Click Run to see the output here. · Haz clic en Ejecutar para ver la salida aquí.