Does anyone know how to make the program running until the ouput becomes 1? If hail(x) = x/2 if x is even(i.e., x%2 is 0) and hail(x) = 3x+1 if x is odd(i.e., x%2 is 1)
example:
Please enter a starting value: 3
Output will be:
3
10
5
16
8
4
2
1
so far wat i came up with was:
Code:
x = int(raw_input("Please enter a starting value:"))
def hail(x):
if x % 2 == 0:
return x / 2
else:
return (3*x)+1
output = hail(x)
print output but i still cant seem to think of a way to make them repeat itself and keep caculating till it becomes one. Any ideas or suggestions?