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, i;
	i = 0;
	while(1)
		{
			cin >> n;
			if ( n == 0 )break;
			else
			{
				while(1)
				{
						if ( n == 1 )break;
						else if ( n % 2 == 1 )
						{
							n = (n * 3) + 1;
							i++;
						}
					else if ( n % 2 == 0 )
						{
							n = n / 2;
							i++;
						}
				}
			cout << i << endl;
			i = 0;
			}	
		}
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<stack>
using namespace std;
#define N 1000002
vector<int> cl(N,0);
class Stack{
	vector<int> v;
	int low;
	int high;
public:
	Stack():v(N,0),low(0),high(0){}
	void push(const int &t){
		++high;
		v[high]=t;
	}
	void pop(int &t){
		t=v[high];
		--high;
	}
	bool empty(){
		return high==low;
	}
} ;
int main()
{
	int c=0;
	Stack stk;
	cl[1]=0;
	stk.push(1);
	while( !stk.empty() ){
		int t;
		stk.pop(t);
		if( t*2<N ){
			if( cl[t*2] == 0 ){
				cl[t*2]=cl[t]+1;
				stk.push(t*2);
			}
		}
		if( (t-1)%3==0&&t>1 ){
			if( cl[(t-1)/3] == 0 ){
				cl[(t-1)/3]=cl[t]+1;
				stk.push((t-1)/3);
			}
		}
	}

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

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

C++: #include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
using namespace std;
int main(){

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

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

int main(){
  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++: main(n,i){for(;scanf("%d",&n),n;printf("%d\n",i))for(i=0;n-1;i++)n=n%2?3*n+1:n/2;exit(0);}

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

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

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

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

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

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

C++: #include <iostream>
main(){for(int n,s;std::cin>>n,n;std::cout<<s<<"\n")for(s=0;n!=1;s++)n = n%2?3*n+1:n/2;}

C++: #include<iostream>

int main()
{
	int n;
	while( std::cin >> n, n )
	{
		int ans = 0;

		while( n != 1 )
		{
			if( n & 1 )
				n = n * 3 + 1;
			else
				n >>= 1;

			++ans;
		}

		std::cout << ans << std::endl;
	}

	return 0;
}

C++: 
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <bitset>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#define strtok_r strtok_s
#endif

#define ITER(c)             __typeof__((c).begin())
#define FOREACH(it, c)      for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)            __typeof__((c).rbegin())
#define RFOREACH(it, c)     for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)           REPEAT(i, 0, n)
#define RREP(i, n)          RREPEAT(i, 0, n)
#define REPEAT(i, k, n)     for(int i = (k); i < ((k)+(n)); ++i)
#define RREPEAT(i, k, n)    for(int i = (k)+(n)-1; i >= (k); --i)
#define FROMTO(i,f,t)       for(int i = f; i < t; i++)
#define ALL(c)              (c).begin(), (c).end()
#define LLPOW(p1,p2)        ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)          (sizeof(A)/sizeof((A)[0]))
#define CIN_NO_SYNC         do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)           fgets((p), sizeof(p), stdin)
#define CHOMP(p)            do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n' || *_q == '\r') *_q = 0; } while(0)
#define FILL(m,v)           memset(m, v, sizeof(m))
#define mp                  make_pair
#define pb                  push_back
template<class _T> _T MAX(_T p1,_T p2){return (p1>p2)?p1:p2;} 
template<class _T> _T MIN(_T p1,_T p2){return (p1<p2)?p1:p2;} 
template <class _Tv> inline string join(const _Tv &v,string sep=" "){
    ostringstream s;FOREACH(it,v){if(it!=v.begin())s<<sep;s<<*it;};return s.str();
}

typedef long long ll;
typedef unsigned long long ull;
typedef double D;
typedef complex<D> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define X real()
#define Y imag()
#define EPS (1e-9)
#define DEQ(p1,p2) (abs((p1)-(p2)) < EPS)

#ifdef _DEBUG
template<class _Tv> inline void _prfe(const char *_n,const _Tv _c,bool _p=false){
    ITER(_c) _it=_c.begin();
    if(_p){cout<<_n<<" = ["<<endl;for(;_it!=_c.end();++_it)cout<<"    "<<*_it<<endl;cout<<"]"<<endl; }
    else{cout<<_n<<" = [ "<<*_it++;for(;_it!=_c.end();++_it)cout<<", "<<*_it;cout<<" ]"<<endl; }
}
#define pf printf
#define pr(n) do{cout<<#n" = "<<(n)<<endl;}while(0)
#define prfe(n) _prfe(#n, n)
#define prfep(n) _prfe(#n, n, true)
#define dbgchk(n) do{if(n)throw;}while(0)
#else
#define pf(...) /* */
#define pr(...) /* */
#define prfe(...) /* */
#define prfep(...) /* */
#define dbgchk(...) /* */
#endif

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

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

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

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

C++: #include<stdio.h>

int main(){
int n,c=0;
while(scanf("%d",&n)!=EOF){
	c=0;
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>
using namespace std;

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