Go: // AOJ Collatz's Problem :http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0158

package main

import (
	"fmt"
)

func main() {
	for {
		var n int

		fmt.Scanf("%d", &n)

		if n == 0 {
			break
		}

		count := 0
		for n != 1 {
			if n%2 == 0 {
				n /= 2
			} else {
				n = n*3 + 1
			}
			count++
		}
		fmt.Println(count)
	}
}

C++: #include<iostream>

using namespace std;

int main(){

  int in;
  
  while(1){

    cin >> in;

    if(in == 0) break;

    int sum = 0;

    while(in != 1){
      if(in % 2 == 0){
	in /= 2;
	sum++;
      }else{
	in = in*3+1;
	sum++;
      }
    }
    cout << sum << endl;

  }

  return 0;
}

C++: #include <stdio.h>

int main(void)
{
	int n = 1;
	int cou = 0;
	while (n != 0){
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		while (n != 1){
			if (n % 2 == 0){
				n /= 2;
			}
			else {
				n = n * 3 + 1;
			}
			
			cou++;
		}
		printf("%d\n", cou);
		cou = 0;
	}
	
	return (0);
}

C++: /*
 * 0158.cpp
 *
 *  Created on: 2011/07/27
 *      Author: isa
 */

#include <iostream>
#include <cstring>

using namespace std;

int m[1000001];

void func(long long num, int times){
	if(num > 1000000 || m[num] != -1) return;
	m[num] = times;
	func(num*2,times+1);
	if((num-1)%3 == 0 && ((num-1)/3)%2 == 1){
		func((num-1)/3, times+1);
	}
}

int main(void){
	int n;
	memset(m,-1,sizeof(m));
	m[1] = 0;
	func(2,1);
	while(cin >> n && n) cout << m[n] << endl;
}

C++: #include<iostream>
#include<string>
#include <algorithm>
#include<iomanip>
#include<cmath>
using std::cin; using std::string;
using std::cout; using std::endl;
using std::sort;
#define rep(X,Y) for(int (X)=0;(X)<(Y);++(X))
#define rept(X,Y,Z) for(int (X)=(Y);(X)<(Z);++(X))
#define repr(X,Y) for(int (X)=(Y);(X)>=0;--(X))
const double pi=3.141592653589793283462;
int main(){
	int n;
	int i=0;
	while(1){
		cin>>n;
		if(n==0)
			break;
	while(1){
		if(n==1)
			break;
		if(n%2==0)
			n=n/2;
		else
			n=n*3+1;
		i++;
	}
	cout<<i<<endl;
	i=0;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
 int n,c;
 while(cin>>n,n){
  for(c=0;n-1;c++){
   if(n%2)n=3*n+1;
   else n/=2;
  }
 cout<<c<<endl;
 }
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define pb push_back

using namespace std;

int main() {
	int n = 1;
	while (n != 0) {
		cin >> n;
		int count = 0;
		while (n != 1) {
			if (n % 2 == 0) n /= 2;
			else n = 3 * n + 1;
			count++;
		}
		cout << count;
	}
}

C++: // 2011/01/17 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

		int cnt = 0;

		while(n!=1){
			if(n%2==0)
				n /= 2;
			else
				n = 3*n+1;
			cnt++;
		}

		cout << cnt << endl;
	}

	return 0;
}

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	long long n;
	while(true){
	cin>>n;
	if(n==0)
		break;
	int i=1;
	while(true){
		if(n==1)
			break;
		if(n%2==0)
			n/=2;
		else{
			n*=3;
			n+=1;
		}
		if(n==1)
			break;
		i++;
	}
	cout<<i<<endl;
	}
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <limits>
using namespace std;
int main(void) {
	for (;;) {
		int cnt = 0,buf;
		cin >> buf;
		if (!buf)return 0;
		for (; buf != 1;) {
			buf = buf % 2 ? buf * 3 + 1 : buf / 2;
			cnt++;
		}
		cout << cnt << endl;
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  while(cin>>n,n){
    int i;
    for(i=0;n!=1;i++) if(n%2) n=n*3+1; else n/=2;
    cout<<i<<endl;
  }
  return 0;
}

C++: #include<iostream>

using namespace std;

int main(void){
	std::ios_base::sync_with_stdio();

	int n;
	int cnt;

	while(1){
		cin>>n;
		if(n==0) break;
		cnt=0;
		while(1){
			if(n==1) break;
			if(n%2==0) n/=2;
			else n=n*3+1;
			cnt++;
		}
		cout<<cnt<<endl;
	}

	return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>


typedef long long ll;
const double Eps = 1e-4;

using namespace std;

int main()
{
	int n;
	while (scanf("%d", &n), n)
	{
		int i;
		for (i = 0; n != 1; ++i)
			n = n & 1 ? 3*n+1 : n/2;
		printf("%d\n", i);
	}

	return 0;
}

C++: #include <cstdio>

int main() {
	int n;
	while (scanf("%d", &n) != EOF) {
		if (n == 0) break;
		int res = 0;
		long long temp = n;
		while (1) {
			if (temp%2 == 0) {
				temp /= 2;
			} else {
				temp = temp * 3 + 1;
			}
			res++;
//			printf("%d\n", temp);
			if (temp == 1) break;
		}
		printf("%d\n", res);
	}
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  long long int n;
  while(cin>>n,n){
    long long int co=0;
    while(n!=1){
      co++;
      if(n%2)n=3*n+1;
      else n/=2;
    }
    cout<<co<<endl;
  }
}

C++: #include<stdio.h>
int main(void)
{
	int n,cnt,i;
	scanf("%d",&n);
	while(n!=0){
		cnt=0;
		while(n!=1){
			if(n%2==0){
				n=n/2;
				cnt++;
			}
			else if(n%2!=0){
				n=(n*3)+1;
				cnt++;
			}
		}
	printf("%d\n",cnt);
	scanf("%d",&n);
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int calc(int n, int k)
{
	if (n == 1) { return k; }

	else if (n % 2 == 0) { return calc(n / 2, k + 1); }

	else if (n % 2 == 1) { return calc(n * 3 + 1, k + 1); }
}

int main()
{
	const int DATASETS = 1000;

	int N[DATASETS], C = 0;

	while (true)
	{
		cin >> N[C];

		if (N[C] == 0) { goto Exit; }

		C++;
	}

Exit:;

	for (int i = 0; i < C; i++)
	{
		cout << calc(N[i], 0) << endl;
	}

	return 0;
}

C++: #include<bits/stdc++.h>

using namespace std;

int main()
{

  while(1){
    int num;
    cin>>num;
    if(num == 0){
      break;
    }

    int ans = 0;
    while(1){
      if(num == 1){
        break;
      }

      if(num % 2 == 0){
        num = num / 2;
      }
      else{
        num = (3 * num) + 1;
      }

      ++ans;
    }

    cout<<ans<<endl;
  }
  
  return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
//#define int long long
using namespace std;

int solve(int n)
{
	int ret = 0;

	while (n != 1)
	{
		if (n % 2 == 0)
		{
			n /= 2;
		}
		else if (n % 2 == 1)
		{
			n = n * 3 + 1;
		}
		ret++;
	}

	return ret;
}

signed main()
{
	int n;

	while (true)
	{
		cin >> n;
		if (n == 0) break;
		printf("%d\n", solve(n));
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	while(cin>>n,n){
		int cnt=0;
		while(n!=1){
			if(n%2)n=n*3+1;
			else n/=2;
			cnt++;
		}
		cout<<cnt<<endl;
	}
}

C++: #include <cstdio>

int main(void)
{
	int n;
	while (scanf("%d", &n)){
		if (n == 0) break;
		
		int res = 0;
		while (n != 1){
			if (n % 2 == 0) n /= 2;
			else n = n * 3 + 1;
			res++;
		}
		
		printf("%d\n", res);
	}
	
	return (0);
}

C++: #include<iostream>
using namespace std;


int main(){
	int n;
	while(cin>>n&&n){
		int c=0;
		while(n-1){
			c++;
			if(n&1)n=3*n+1;
			else n>>=1;
		}
		cout<<c<<endl;
	}
	return 0;
}