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;

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

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

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

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

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

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

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

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

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

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

  return 0;
}

C++: #include <iostream>

int main()
{
	int n;
	while (true) {
		std::cin >> n;
		if (n==0) break;
		int count = 0;
		while (n>1) {
			if ((n&1)==1) n = 3*n+1;
			else n /= 2;
			count++;
		}
		std::cout << count << std::endl;
	}
	return 0;
}

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

int main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	for(int n; cin >> n && n;) {
		int cnt = 0;
		while(n > 1) {
			++cnt;
			if(n & 1) {
				n = n * 3 + 1;
			}
			else {
				n >>= 1;
			}
		}
		cout << cnt << endl;
	}

	return EXIT_SUCCESS;
}

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

int a[1000000];

int colpro(int m){
    if(a[m] >= 0){
    }else if(m % 2 == 0){
        int ret = colpro(m / 2);
        a[m] = ret + 1;
    }else{
        int ret = colpro(3 * m + 1);
        a[m] = ret + 1;
    }
    return a[m];
}

int main(){
    for(int i = 0; i < 1000000; i++){
        a[i] = -1;
    }
    a[1] = 0;
    a[2] = 1;
    a[3] = 7;
    a[4] = 2;
    a[5] = 5;
    a[8] = 3;
    a[10] = 6;
    a[20] = 7;
    a[21] = 7;
    a[16] = 4;
    a[32] = 5;
    a[64] = 6;
    a[128] = 7;
    for(;;){
        int n;
        if(cin >> n){
            if(n == 0){
                break;
            }
            int l = 0;
            cout << colpro(n);
        }else{
            break;
        }
    }
    return 0;
}

C++: #include<stdio.h>
int main()
{
	int n,c;
	while(scanf("%d",&n),n)
	{
		for(c=0;n-1;++c) n=(n&1?3*n+1:n/2);
		printf("%d\n",c);
	}
	return 0;
}

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

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

C++: #include <cstdio>
#include <cstring>
#include <queue>
#include <map>
using namespace std;
typedef pair<int, int> P;
int n;
int dp[1000001];
queue<P> que;
int main() {
    memset(dp, 0, sizeof(dp));
    que.push(P(2,1));
    while (!que.empty()) {
        P p=que.front(); que.pop();
        if (dp[p.first]) continue;
        dp[p.first]=p.second;
        if (p.first!=4&&(p.first-1)%3==0) {
            que.push(P((p.first-1)/3,p.second+1));
        }
        if (p.first*2<1000001) {
            que.push(P(p.first*2,p.second+1));
        }
    }
    // for (int i=1; i<=10; i++) printf("%d%c",dp[i],i==10?'\n':' ');
    while (scanf("%d",&n)) {
        if (!n) break;
        printf("%d\n",dp[n]);
    }
}

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

using namespace std;

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

C++: #include <iostream>

using namespace std;

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

C++: # define _CRT_SECURE_NO_WARNINGS 1
# define _USE_MATH_DEFINES
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;
# define INF ((int)(1<<25))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,n) REP(i,n)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define ALL(x) (x).begin(),(x).end()
# define RALL(x) (x).rbegin(),(x).rend()
# define DEBUG(x) cout<<#x<<" :"<<x<<endl;
# define EPS 1e-12
template<class T> void debug(T a) { for (auto i : a)cout << i << endl; }
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };

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