Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		n, _ := strconv.Atoi(scanner.Text())
		if n == 0 {
			break
		}
		k := 0
		for n > 1 {
			if n&1 != 0 {
				n = n+((n+1)>>1)
				k+=2
			} else {
				n >>= 1
				k++
			}
		}
		fmt.Println(k)
	}
}

C++: #include<iostream>
using namespace std;
int main(){
  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=n/2;
	cnt++;
      }
      if(n%2!=0&&n!=1){
	n=n*3+1;
	cnt++;
      }
    }
    cout<<cnt<<endl;
  }
  return 0;
}

C++: #include<iostream>
#include<vector>
#include<stack>
using namespace std;
#define N 1000002
vector<int> cl(N,-1);
int collatz(int n){
	int c=0;
	while(n<N){
		if(cl[n]!=-1)
			return c+cl[n];
		if(n%2==0){
			n/=2;
			++c;
		}else if(n%2==1){
			n=n*3+1;
			++c;
		}
	}
	return 0;
}
int main()
{
	cl[1]=0;
	for(int i = 1; i < N; ++i){
		cl[i] = collatz(i);
	}

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

		cout << cl[n] << endl;
	}
	return 0;
}

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

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

  return 0;
}

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

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int MAXN = 1000 * 1000 + 10;

int d[MAXN] = {};

int solve(int n)
{
    if(n == 1) return 0;
    if(d[n] != 0) return d[n];

    if(n % 2)
        d[n]= 1 + solve( n * 3 + 1);
    
    else d[n] = 1 + solve(n / 2);

    return d[n];
}

int main()
{
    int n;
    while(cin >> n && n) 
    {
        cout << solve(n) << endl;
    }
    return 0;
}

C++: #include<stdio.h>
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
    int a,b;
    int n=0;
    while(cin>>n)
    {
        int cnt=0;
        if(n==0)break;
        for(;;)
        {
            if(n==1)break;
            if(n%2==0)
            {
                //cout<<"ok"<<endl;
                n/=2;
                cnt++;
            }
            else if(n%2!=0)
            {
                //cout<<"3ok"<<endl;
                n*=3;
                n+=1;
                cnt++;
            }
        }
        cout<<cnt<<endl;
    }
    return 0;
}

C++: #include<iostream>

using namespace std;

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

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

int main(){
	int n, cnt, x;
	while(cin>>n&&n){
		x=n;
		cnt=0;
		while(x>1){
			if(x%2){
				x+=x*2+1;
			}else{//gusu
				x/=2;
			}
			cnt++;
		}
		cout<<cnt<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
int main(void){
    int n,count,i,j,ans;
    while(1){
        count=0;
        cin >> n;
        if(n == 0)break;
        while(n != 1){
            if(n%2 == 0){
                n=n/2;
                count++;
            }
            else{
                n=(n*3)+1;
                count++;
            }
        }
        cout << count << endl;
    }
}

C++: #include <bits/stdc++.h>
using namespace std;

// template {{{
/* vim: set foldmethod=marker: */

// constant
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;
const double PI = acos(-1);
#define EPS 1e-14

// typedef
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;

// input
inline int inputi(){ int x; scanf("%d", &x); return x; }
inline double inputd(){ double x; scanf("%lf", &x); return x; }
inline string inputs(){ string x; cin >> x; return x; }

// short
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define REPit(type, i, obj) for (type::iterator i = (obj).begin(); i != (obj).end(); i++)
#define RREPit(type, i, obj) for (type::iterator i = (obj).rbegin(); i != (obj).rend(); i++)

// container util
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define sz(obj) ((int)(obj).size())
#define sort(obj) sort(all(obj))
#define exist(obj, key) ((obj).find(key) != (obj).end())
#define clear(array) memset((array), 0, sizeof(array))

// print util
#define print(x) cout << (x) << endl
template <class T> inline void printall(vector<T> v){ REP(i, sz(v)) cout << v[i] << "\n "[i < sz(v) - 1]; }
#define dump(x) cerr << #x << ": " << (x) << endl
#define debug(x) cerr << #x << ": " << (x) << " (" << __LINE__ << ")" << endl

//template }}}

int main()
{
    int n;
    while (n = inputi(), n){
        int cnt = 0;
        while (n != 1){
            n = n % 2 ? n * 3 + 1 : n / 2;
            cnt++;
        }
        print(cnt);
    }

    return 0;
}

C++: #include<stdio.h>

int main(){
int n,c=0;
while(scanf("%d",&n)!=EOF){

while(n!=1){
if(n%2==1)n=n*3+1;
else if(n%2==0)n=n/2;
c++;
}
printf("%d\n",c);
}
return 0;
}

C++: #include <iostream>
#include <cstdio>

using namespace std;


int main() {

  int n;

  while(1) {

  cin >> n;
  if(n == 0) break;

  int count = 0;

  while(n != 1) {

    count ++;

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

  cout << count << endl;

  }

  return 0;

}

C++: #include <cstdio>

int main() {
	int n;
	while (scanf("%d", &n)) {
		if (n == 0) break;
		long long int res = 0;
		long long int 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("%lld\n", res);
	}
}

C++: #include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    while(cin >> n, n){
        int cur = 0;
        while(n != 1){
            if(n&1) n = n*3+1;
            else n /= 2;
            cur++;
        }
        cout << cur << "\n";
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

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

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; !i || n != 1; ++i)
			n = n & 1 ? 3*n+1 : n/2;
		printf("%d\n", i);
	}

	return 0;
}