How many halvings? · Quantas divisões por dois?
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.
Quantas divisões por dois?
n começa em 40. Divida por dois com n = n // 2 até chegar em 0, contando os passos em steps.
// divide e descarta o resto, então 5 // 2 é 2. Contar quantas vezes um loop rodou precisa de sua própria variável, somando um a cada volta.
n starts at 40. Halve it with n = n // 2 until it reaches 0, counting the steps in steps. · n começa em 40. Divida por dois com n = n // 2 até chegar em 0, contando os passos em steps.
Click Run to see the output here. · Clique em Executar para ver a saída aqui.