Skip to content · ⁨Saltar al contenido⁩

Stop at the first over fifty · ⁨Detenerse en el primer valor mayor que 50⁩

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.

Español

Detenerse en el primer valor superior a cincuenta

n comienza en 1. Se le suma 1 constantemente. Tan pronto como n * n sea mayor que 50, se sale del bucle con break. Después, se imprime n.

break abandona el bucle de inmediato. ⚠️ Solo funciona dentro del bucle, por lo que el if que lo contiene también debe estar indentado bajo el while — y el break una vez más, indentado debajo del if. print(n) permanece alineado a la izquierda, fuera del bucle, para que se ejecute tras la salida.

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

IGCSE, A-Level & AP