Topic Link -> Link
Thinking
- According to the meaning of the questions to determine the cumulative parity.
Code
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <iostream>
using namespace std;
int main(){
int n,count=0;
scanf("%d",&n);
while(n!=1){
if(n%2==0){
n/=2;
count++;
}
else {
n=(3*n+1)/2;
count++;
}
}
printf("%d\n",count);
return 0;
}