How many halvings? · 何回半分に分割したか?
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · このページには最新のブラウザ(SharedArrayBuffer対応)が必要です。Chrome、Edge、Firefox、Safariを最新バージョンに更新してください。
This one builds on a lesson you haven't finished yet. Do that lesson first: · これはまだ完了していないレッスンの先にある内容です。まずはそのレッスンを済ませてください:
Python Basics · While loops →
English
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. · 実行ボタンをクリックして出力を確認してください。