Evolution stage
If N is even N/2
If N is odd N * 3+1 and point steps to reach 1 . Ex: 10is even 10/2=5, 5 is odd 5*3+1=16, 16 is even 16/2= 8 and 8/2=4 and 4/2= 2 and 2/2 =1
So the output is 6
print("Enter n: ")
n = int( input() )
count = 0
while(n!=1):
if(n%2==0):
n/=2
else:
n=n*3+1
count+=1
print(count)
Comments
Leave a comment