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. ค้างคูณสองwhile它还 ≤ 100. เก็บค่าแรกที่ > 100 ใน n
ที่นี่ค่าที่ทดสอบคือค่าที่เปลี่ยน ดังนั้นลูปไม่ต้องมีตัวนับแยกต่างหาก มันหยุดทันทีที่คำถามกลายเป็นfalse — และ n ยังคงเก็บค่าที่ทำให้มันfalse
n starts at 1. Keep doubling it while it is 100 or less. Store the first value over 100 in n. · n เริ่มที่ 1. ค้างคูณสองwhile它还 ≤ 100. เก็บค่าแรกที่ > 100 ใน n
Click Run to see the output here. · คลิก Run เพื่อดูผลลัพธ์ที่นี่