I need to test whether n is a multiple of 2 and then divide the number by 2. If the number isn't a multiple of 2, then I have to do 3*n+2.
How do I make it loop so I can get the following: 12, 6, 3, 10, 5, 16, 8, 4, 2, 1?
Here's my current code:
n=12
while n!=0:
if n%2==0:
print (n)
n=n/2
if n!=n%2:
if n !=1:
n = 3*n+2
else:
break
print(n)