Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int main()
- {
- int i,j;
- for(;;)
- {
- cin>>i>>j;
- cout<<i<<" "<<j<<" ";
- if(i>j)
- {
- swap(i,j);
- }
- int max=0;
- int count=1;
- int n;
- for(int k=i;k<=j;k++)
- {
- n=k;
- while(n!=1)
- {
- if(n%2==0)
- {
- n=n/2;
- }
- else if(n%2==1)
- {
- n=n*3+1;
- }
- count++;
- }
- if(count>max)
- {
- max=count;
- }
- count=1;
- }
- cout<<max<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement