Read post
#include<stdio.h>
int main()
{
int a,b;
int tempa,tempb;
int temp,k;
int i=1,j=1;
do
{
scanf("%d %d",&a,&b);
if(a>b)
{
tempa=b;
tempb=a;
}
else
{
tempa=a;
tempb=b;
}
for(k=tempa;k<=tempb;k++)
{
temp=k;
while(temp!=1)
{
if(temp%2==0)
{
temp=temp/2;
j++;
}
else
{
temp=temp*3+1;
j++;
}
if(j>i) i=j;
}
j=1;
}
printf("%d %d %d\n",a,b,i);
i=1;
}while(getchar()!=EOF);
return 0;
}
Reply
|