Daffodil International University
Problem Link
//Please follow from main function
#include<stdio.h>
int main()
{
int i, n, temp, m, c=1;
while(1){
scanf("%d %d", &n, &m);
if(n>m){
temp=n;
n=m;
m=temp;
}
for(i=n; i<=m; i++){
for(; ;){
printf("%d ", i);
if(i==1){
break;
}
else if(i%2==0){
i=i/2;
}else{
i=3*i+1;
}
c++;
}
printf("\t%d\n", c);
c=1;
}
}
return 0;
}
0 Comments