Answer to Question #346014 in Python for Gdr

Question #346014

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

1
Expert's answer
2022-05-30T15:15:05-0400
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)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS