Looping Through Complexity: 36 Loop Problems to Practice Solving

btd
37 min readFeb 1, 2024
Photo by Li Zhang on Unsplash

1. How many times does the following loop run?

i = 0
j = 1
while j >= 1 :
print("" , i , ";" , j)
i = j + 1
if i % 2 == 0 :
j = j - 1
2 times
  1. Initialization:
  • i is initialized to 0.
  • j is initialized to 1.

--

--