1
2
3
4
5
6
7
8
9
10
11
12
#include <cstdio>
int main(){
int n, step = 0;
scanf("%d",&n);
while(n!=1){
if(n%2==0)n=n/2;
else n=(3*n+1)
step++;
}
printf("%d",step);
return 0;
}

Comments

2018-04-29

⬆︎TOP