代碼:
#include <stdio.h>
int main()
{
long A,L,num=1,a;
int j=1;
while(scanf("%ld%ld",&A,&L)==2&&A>0&&L>0)
{
num=1;
a=A;
while(A>1)
{
if(A%2==0)
A/=2;
else
{
A=3*A+1;
if (A>L)
{
break;
}
}
num++;
}
printf("Case %d: A = %d, limit = %d, number of terms = %d\n",j,a,L,num);
j++;
}
return 0;
}