#include int loop_length(int n); int greater_loop(int n1, int n2); int main () { int i,j,k; while ( scanf("%d %d",&i,&j) != EOF) { k = greater_loop(i,j); printf("%d %d %d\n",i,j,k); } return 0; } int greater_loop(int n1, int n2) { int greater, this; /* greater: maior loop até agora. * this : loop atual. */ int tmp; greater = 0; if (n2 < n1) { tmp=n1; n1=n2; n2=tmp; } for (tmp = n1; tmp <= n2; tmp++) { this = loop_length(tmp); if (this > greater) { greater = this; } } return greater; } int loop_length(int n) { int counter=1; while (n != 1) { if ((n%2) == 0) { /* Numero Par: n=n/2 */ n/=2; } else { /* Numero Impar: n=3n+1 */ n*=3; n++; } counter++; } return counter; } /* author: Gustavo Sverzut Barbieri (http://www.gustavobarbieri.com.br) */