while statement has an else part.
n = 10
steps = 0
while n != 1:
if n % 2 == 0:
n //= 2
else:
n = 3 * n + 1
steps += 1
else:
print("done", end=" ")
print(steps)
What does the program print?Log in to join the discussion.
Loading…