| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- #include <iostream>
- using namespace std;
- int main(){
- int i, j, n = 0;
- int cyc = 0, cyc_max = 0;
- while(cin >> i >> j)
- {
- // if(cyc_max)
- // cout << endl;
- cyc_max = 0;
- for(int q = min(i,j); q <= max(i,j); q++)
- {
- n = q;
- cyc = 1;
- while (n != 1)
- {
- if (n%2 == 1) // Om n inte är ett heltal gör ->
- n = 3*n+1;
- else
- n = n/2; // Om n är ett heltal gör ->
- cyc++;
- }
- cyc_max = max(cyc_max, cyc);
- }
- cout << i << " " << j << " " << cyc_max << endl;
- }
- return 0;
- }
|