fork(1) download
  1. #include <stdio.h>
  2. int main()
  3. {
  4. int n,i,j,count,start,end,m=0;
  5. scanf("%d %d", &start,&end);
  6. for(j=start;j<=end;j++){
  7. count=2;
  8. i=j;
  9. for(n=0;n<=10000000;n++){
  10.  
  11. if(i%2==0){
  12. i=i/2;
  13. }
  14. else if(i%2!=0){
  15. i=3*i+1;
  16. }
  17. if(i==1){
  18. break;
  19. }
  20. count++;
  21.  
  22. }
  23. if(m<count){
  24. m=count;
  25.  
  26. }
  27.  
  28.  
  29. }
  30. printf("%d\n", m);
  31. return 0;
  32. }
  33.  
Success #stdin #stdout 0s 2056KB
stdin
Standard input is empty
stdout
0