Karaz (Callatz) conjecture:
n If it is an even number, cut it off by half, and if it is an odd number, n =1. Karaz at the 1950 World Mathematicians conference published this conjecture, the legend of the Yale University teachers and students to mobilize, desperately want to prove this seemingly silly very naïve proposition, the result of students do not want to study, the heart only card (, That some say it is a conspiracy, Karaz is deliberately delaying the progress of teaching and scientific research in the American mathematics field ...
Our topic today is not to prove Karaz conjecture, but to give no more than 1000 positive integers N, simply to count, how many steps (a few cuts) are needed to get n=1?
Input Format:
Each test input contains 1 test cases, giving the value of the positive integer n.
output Format:
Outputs the Number of steps required to calculate from N to 1.
Input Sample:
3
Sample output:
5
1#include <iostream>2 using namespacestd;3 4 intMain () {5 intN;6 intCnt=0;7Cin>>N;8 while(n!=1){9 if(n%2){TenN= (3*n+1)/2; Onecnt++; A } - Else{ -N/=2; thecnt++; - } - } -cout<<CNT; + return 0; -}
pat-Serie B-1001 deaths (3N+1) conjecture