Skip to content · ⁨דלג לתוכן⁩

Stop at the first over fifty · ⁨להעצור בראשונה מעבר לחמישים⁩

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.

עברית

עצור בראשית החריגה מ-50

n מתחיל ב-1. המשך להוסיף לו 1. ברגע ש-n * n גדול מ-50,צא מהלולאה עם break. הדפס את n לאחר מכן.

break יוצא מהלולאה מיד. ⚠️ הפקודה עובדת רק בתוך הלולאה, ולכן ה-if שמחזיק אותה חייב להיות מוזז בתוכיה יחד עם ה-while — וה-break מוזז פעם נוספת, מתחת ל-if. ה-print(n) נשאר משמאל, מחוץ ללולאה, כך שהוא יופעל לאחר ה-break.

Log in or create account · ⁨היכנס או צור חשבון⁩

IGCSE, A-Level & AP