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