Double until it passes 100 · להכפיל פי שניים עד שעובר את 100
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 שומר את הערך שהוביל לכך.
n starts at 1. Keep doubling it while it is 100 or less. Store the first value over 100 in n. · n מתחיל ב1. המשך להכפיל אותו פי שניים כל עוד הוא קטן או שווה ל100. אחסן את הערך הראשון הגדול מ100 בn.
Click Run to see the output here. · לחץ על הרץ כדי לראות את התוצא כאן.