topic:
Parity reunification conjecture - how many steps to reconcile. (10 points)
Question content:
Parity Conjecture - For every positive integer, if it's odd, multiply it by 3 and add 1, if it's even, divide it by 2, and so on, and you'll get 1 in the end. If n = 11, the sequence is: 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1. (14 steps in total)
The question enters a positive integer n, how many steps can this n be normalized
Input format:
a positive integer
Output format:
a positive integer
Input sample:
11
Sample output:
14
coding:
#include<stdio.h> intmain() { int n,i=0; scanf("%d",&n); while(n!=1) { int tmp=n%2; if(tmp == 0) { n=n/2; i++; }else if (tmp == 1) { n=n*3+1; i++; } } printf("%d",i); return 0; }