题解 | #xxx定律#
xxx定律
http://www.nowcoder.com/practice/75c189249d6145cfa33cd53edae6afc8
//算法笔记p85 害死人不偿命的(3n+1)猜想 卡拉兹猜想
#include<stdio.h>
int main()
{
int n,step=0;
while(scanf("%d",&n)!=EOF)
{
while(n!=1)
{
if(n%2==0)
{
n=n/2;
}
else
{
n=(3*n+1)/2;
}
step+=1;
}
printf("%d\n",step);
return 0;
}
}