Advertisement
Kawsar_Hossain

Untitled

Apr 6th, 2020
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int a,b,i,n,j,c=0,max=0;
  5. while(scanf("%d %d",&a,&b)!=EOF)
  6. {
  7. if(n>0 && n<10000)
  8. {
  9. for(i=a; i<=b; i++)
  10. {
  11. n=i;
  12. while(1)
  13. {
  14. if(n==1)
  15. {
  16. c++;
  17. break;
  18. }
  19. else if(n%2!=0)
  20. {
  21. n=(3*n)+1;
  22. c++;
  23. }
  24. else if(n%2==0)
  25. {
  26. n=n/2;
  27. c++;
  28. }
  29.  
  30. }
  31. if(c>max)
  32. {
  33. max=c;
  34. }
  35. c=0;
  36. }
  37. printf("%d %d %d\n",a,b,max);
  38. max=0;
  39. c=0;
  40. }
  41. }
  42.  
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement