[Solved] Why does this loop only once? [closed]


Your inner conditionals don’t make sense with the while. And you have a return statement in the loop, so yes, it only looped once.

Start with this

import math

n, count = (1003, 3)
print("N = " + str(n))
while count > 0:
  n = math.ceil((n - 5) / 2)  # Update this to do whatever your logic is
  print(count, n)
  count -= 1
if n < 0:
  print("N is negative")
else:
  print("N = " + str(n))

solved Why does this loop only once? [closed]