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. การนับ กี่ครั้ง ลูปวนรอบ ต้องมีตัวแปรของตัวเองเพิ่มขึ้นหนึ่งทุกรอบ
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. · คลิก Run เพื่อดูผลลัพธ์ที่นี่