65.4k views
3 votes
Given positive integer numInsects, write a while loop that prints that number doubled without reaching 200. Follow each number with a space. After the loop, print a newline. Ex: If numInsects= 16, print:

16 32 64 128

1 Answer

4 votes

Answer:

numInsects = 16

while numInsects < 200:

print(str(numInsects) + " ", end="")

numInsects *= 2

Step-by-step explanation:

*The code is in Python.

Set the numInsects as 16

Create a while loop that iterates while numInsects is smaller than 200. Inside the loop, print the value of numInsects followed by a space. Then, multiply the numInsects by 2.

User Roim
by
4.8k points