1001. 害死人不偿命的(3n+1)猜想 (15)
较简单,直接代码实现:
#include <cstdio>
int main()
{
int n;
scanf("%d",&n);
int k =0;
while(n!=1)
{
if(n%2 == 0)
{
k++;
n = n/2;
}
else
{
n = 3*n+1;
}
}
printf("%d
",k);
return 0;
}