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>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <limits>
#include <cmath>
#include <cassert>

using namespace std;
using ll = long long;

const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    while(cin >> n, n)
    {
        ll cnt = 0;
        while(n != 1)
        {
            if(n % 2 == 0) n /= 2LL;
            else n = 3LL * n + 1LL;
            cnt++;
        }
        cout << cnt << endl;
    }
    return 0;
}

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

C++: #include <iostream>
#include <vector>
#define LIM 3000010

using namespace std;

int step[LIM]={0};

int rec(int n){
	
	if(n==1)
		return 0;
	else if(step[n] != 0)
		return step[n];
	
	if(n%2)//odd
		return step[n] = rec(n*3+1)+1;
	else//even
		return step[n] = rec(n/2)+1;
}

int main(){

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

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

C++: #include <iostream>

using namespace std;

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

int main()
{
	solve();
	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>
using namespace std;

int main(){
  int n;

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

  return 0;
}

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

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

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

int main(void)
{
	int n;

	while(cin >> n, n){
		int c = 0;

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

	return 0;
}

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

int n;

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

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

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

C++: #include <iostream>

using namespace std;

int main(void)
{
	int n;
	int answer;

	while( cin >> n && n != 0 ){
		answer = 0;

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

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

#define int long long

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

signed main() {
    int n;
    while(cin>>n, n!=0) {
        int ans = 0;
        while(n!=1) {
            n = clz(n);
            ans++;
        }
        cout << ans << endl;
    }
    return 0;
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define CC puts("-------ok--------");
#define all(in) in.begin(), in.end()
#define bv vector<bool>
using namespace std;
typedef pair<int, int>PA;
using namespace std;
#define MAX 1e7
int main(){
    int n;
    while(cin >> n,n){
        int ans = 0;
        while (true) {
            if(n ==1) break;
            if(n %2 == 1)
            { n*=3; n+=1; ans++;}
            if(n % 2 == 0)
            {n = n/2; ans++;}
        }
        cout << ans << endl;
            }
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

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

C++: #include <stdio.h>
#include <cmath>
#include <algorithm>
#include <queue>

using namespace std;



int main(){

	int n,count;

	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		count = 0;

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

		printf("%d\n",count);
	}

    return 0;
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;

template<class T> ostream& operator << ( ostream& os, vector<T> v ) {
    for ( typename vector<T>::iterator it_i = v.begin(); it_i != v.end(); ++it_i ) {
        os << *it_i << ", ";
    }
    return os;
}


int solve( int n ) {
    int res = 0;
    while ( n > 1 ) {
        res ++;
        n = ( n % 2 == 0 ? n / 2 : n * 3 + 1 );
    }
    return res;
}

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

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,a,b) for(int i=(a); i<(b); i++)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int IMAX=((1<<30)-1)*2+1;
const double EPS=1e-10;
//int mod=1000000007;



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

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