Skip to content · ⁨Pular para o conteúdo⁩

Stop at the first over fifty · ⁨Parar no primeiro acima de cinquenta⁩

English

Stop at the first over fifty

n starts at 1. Keep adding 1 to it. As soon as n * n is more than 50, leave the loop with break. Print n afterwards.

break leaves the loop at once. ⚠️ It only works inside the loop, so the if that holds it must be indented under the while too — and the break indented once more, under the if. print(n) stays at the left, outside the loop, so it runs after the break.

Português

Parar no primeiro acima de cinquenta

n começa em 1. Continue somando 1 a ele. Assim que n * n for maior que 50, saia do loop com break. Imprima n depois.

break sai do loop imediatamente. ⚠️ Ele só funciona dentro do loop, então a if que o segura também deve estar indentada sob o while — e a break indentada mais uma vez, sob o if. print(n) fica na margem esquerda, fora do loop, então roda depois do break.

Log in or create account · ⁨Entrar ou criar conta⁩

IGCSE, A-Level & AP