How many halvings? · כמה חלוקות למחצית?
How many halvings?
n starts at 40. Halve it with n = n // 2 until it reaches 0, counting the steps in steps.
// divides and throws the remainder away, so 5 // 2 is 2. Counting how many times a loop went round needs its own variable, going up by one each turn.
כמה חלוקות?
n מתחיל ב-40. חלק אותו ב-n = n // 2 עד שהגיע ל-0, סופר את הצעדים ב-steps.
// מחלק ומשליך שאריות, ולכן ה-5 // 2 הוא 2. ספירת כמה פעמים לולאה עברה סביבה דורשת משתנה משלו, העולה ב-1 בכל סיבוב.
n starts at 40. Halve it with n = n // 2 until it reaches 0, counting the steps in steps. · n מתחיל ב-40. חלק אותו ב-n = n // 2 עד שהגיע ל-0, סופר את הצעדים ב-steps.
Click Run to see the output here. · לחץ על הרץ כדי לראות את התוצא כאן.