PAT killed attractiveness of the (3n + 1) guess

Kharazi (Callatz) guess:

For any positive integer n, if it is even, then it halved; if it is odd, the (3n + 1) cut by half. This has been repeatedly cut, finally got to get n = 1 in a step. Kharazi at the 1950 World Congress of Mathematicians announced this conjecture, was the legendary Yale University teachers and students Qidong Yuan, desperately want to prove this seemingly silly naive proposition, students inadvertently result so much noise studies, one only card (3n +1), so some people say this is a conspiracy, Kharazi was deliberately delaying the progress of American mathematics teaching and research ...

Our topic today is not evidence Minka Raz conjecture, but on any given positive integer not exceeding 1,000 n, simply count the number, how many steps (cut a few) need to get 1?

Input formats:

Each test comprises a test input, i.e., the value given positive integer n.

Output formats:

N is calculated from the output to a desired number of steps.

Sample input:

3

Sample output:

5
n=int(input())
x=0
while n!=1:
    if n%2==0:
        n=n//2
    else:
        n=(3*n+1)//2
    x+=1
print(x)

Guess you like

Origin www.cnblogs.com/andrew3/p/12664142.html