main()
{
long long int k=1000000;
int n=1;
int large=1;
long long int p;
while(k>=1){
p=k;
while(p!=1)
{
if(p%2!=0){p=3*p+1;n++;}
else{if(p%2==0){p/=2;n++;}}
}
if(n>large){large=n;}
n=1;
k--;
}
k=1000000;
while(k>=13){
p=k;
while(p!=1)
{
if(p%2!=0){p=3*p+1;n++;}
else{if(p%2==0){p/=2;n++;}}
if(n==large){printf("%d\n",k);break;}
}
n=1;
k--;
}
}
{
long long int k=1000000;
int n=1;
int large=1;
long long int p;
while(k>=1){
p=k;
while(p!=1)
{
if(p%2!=0){p=3*p+1;n++;}
else{if(p%2==0){p/=2;n++;}}
}
if(n>large){large=n;}
n=1;
k--;
}
k=1000000;
while(k>=13){
p=k;
while(p!=1)
{
if(p%2!=0){p=3*p+1;n++;}
else{if(p%2==0){p/=2;n++;}}
if(n==large){printf("%d\n",k);break;}
}
n=1;
k--;
}
}
No comments:
Post a Comment