Learn to code with step-by-step lessons. A place for students to work through programming fundamentals and build skills.
One possible program:
current_value = int(input("Starting n (positive): "))
steps = 0
while current_value != 1:
if current_value % 2 == 0:
current_value = current_value // 2
else:
current_value = 3 * current_value + 1
steps += 1
print("Steps to reach 1:", steps)