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

Double until it passes 100 · ⁨להכפיל פי שניים עד שעובר את 100⁩

English

Double until it passes 100

n starts at 1. Keep doubling it while it is 100 or less. Store the first value over 100 in n.

Here the value being tested is the value being changed, so the loop needs no separate counter. It stops the moment the question turns false — and n keeps the value that made it false.

עברית

הכפלה עד מעבר מ-100

n מתחיל ב1. המשך להכפיל אותו פי שניים כל עוד הוא קטן או שווה ל100. אחסן את הערך הראשון הגדול מ100 בn.

במקרה זה, הערך הנבדק הוא אותו ערך המשתנה, ולכן ללולאה אין צורך בסופר נפרד. הלולאה עצרת ברגע שהתנאי הופך לשקר — ו-n שומר את הערך שהוביל לכך.

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

IGCSE, A-Level & AP