魔法数字变换
魔法数字变换
http://www.nowcoder.com/questionTerminal/db41a6ce80a646aa9a5eb6252ac2df76
include<stdio.h>
main()
{int n,m;
scanf("%d",&n);
for(m=0;n!=1;m++)
{if(n%2==0)n/=2;
else
n=3*n+1;}
printf("%d",m);}
魔法数字变换
http://www.nowcoder.com/questionTerminal/db41a6ce80a646aa9a5eb6252ac2df76
main()
{int n,m;
scanf("%d",&n);
for(m=0;n!=1;m++)
{if(n%2==0)n/=2;
else
n=3*n+1;}
printf("%d",m);}
相关推荐