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 <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rrep(i,n) for(int i=(int)(n)-1; i>=0; i--)
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin(); it!=(c).end(); it++)
#define pb(a) push_back(a)
#define pr(a) cout << (a) << endl
#define PR(a,b) cout << (a) << " " << (b) << endl
#define F first
#define S second
typedef long long ll;
typedef pair<int,int> P;
const int MAX=1000000001;
const ll MAXL=1000000000000000001LL;
const ll mod=1000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

set<int> s;
int main() {
  for(int n; cin >> n && n;) {
    s.clear();
    while(n!=1) {
      s.insert(n);
      if(n%2) n=n*3+1;
      else n/=2;
    }
    pr(s.size());
  }
  return 0;
}

C++: #include <cstdio>

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

C++: #include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;
int dp[1010010];
int foo(int a){
	if(dp[a]>=0) return dp[a];
	if(a%2){
		return dp[a]=foo(a*3+1)+1;
	}
	return dp[a]=foo(a/2)+1;
}

void mainmain(){
	int n;
	rep(i,1010010) dp[i]=-1;
	dp[1]=0;
	while(cin>>n,n){
		cout<<foo(n)<<endl;
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

C++: #include <cstdio>

int n;

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

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 (cin >> 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(void)
{
	int n,m,c;
	scanf("%d",&n);
	while(n!=0){
		c=0; m=n;
		while(m!=1){
			if(m%2==0) m=m/2;
			else m=m*3+1; c++;
		}
		printf("%d\n",c);
		scanf("%d",&n);
	}
	return 0;
}

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

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

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

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

C++: // #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>	// istringstream
using namespace std;

int solve(int n){
	int count = 0;
	while (n != 1){
		if (n % 2 == 0)
			n /= 2;
		else
			n = n * 3 + 1;
		count++;
	}
	return count;
}

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

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

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

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

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

C++: #include<cstdio>

int main()
{
	int a,i,j=0,count[1000];
	while(1)
	{
		scanf("%d",&a);
		if(a==0)
			break;
		i=0;
		while(a!=1)
		{
			if(a%2==0)
				a=a/2;
			else
				a=a*3+1;
			i++;
		}
		count[j]=i;
		j++;
	}
	for(i=0;i<j;i++)
		printf("%d\n",count[i]);
	return 0;
}

C++: #include<iostream>
using namespace std;
int n,i;
int main(){
  while(cin>>n&&n){
    for(i=0;n!=1;i++){
      n=(n&1?n*3+1:n/2);
    }
    cout<<i<<endl;
  }
  return 0;
}

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