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

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

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

  return 0;
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

static const double eps = 10e-8;

int main(){
	ll n;
	while(~scanf("%lld",&n)){
		if(n==0) break;
		int res=0;
		while(n!=1){
			if(n%2) n=n*3+1;
			else n/=2;
			res++;
		}

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

C++: #include<stdio.h>
int main(void)
{
	int n;
	int cnt;

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

C++: #include<iostream>
using namespace std;
int main(){
long n,k;
while(cin>>n){
if(n==0)break;
for(k=1;;k++){
if(n/2*2==n)n/=2;else n=3*n+1;
if(n==1)break;
}
cout<<k<<endl;
}
return 0;
}

C++: #define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
#define FOR(i,n) for(int i = 0; i < (n); i++)
#define sz(c) ((int)c.size())

typedef unsigned long long ull;
const int INF = (int)1e8;


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

C++: #include <iostream>

using namespace std;

bool even(int n) {
    if (n % 2 == 0) return true;
    return false;
}

int count(int n, int acc) {
    if (n==1) return acc;
    if (even(n)) {
        return count(n/2, acc+1);
    }
    return count(n*3+1, acc+1);
}

int main() {
    int n;
    while (cin >> n) {
        if (n == 0) break;
        cout << count(n, 0) << endl;
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
long n,k;
while(cin>>n){
if(n==0)break;
for(k=0;;k++){
if(n==1)break;
if(n/2*2==n)n/=2;else n=3*n+1;
}
cout<<k<<endl;
}
return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int in;
  while(cin>>in,in){
    int co=0;
    while(in!=1){
      co++;
      if(in%2)in=in*3+1;
      else in/=2;
    }
    cout<<co<<endl;
  }


}

C++: #include<cstdio>
using namespace std;
int main(){
    int n;

    while(scanf("%d",&n),n){
        int cnt = 0;
        for(;;){
            if(n == 1)break;
            if(n%2 == 0)n /= 2;
            else n = (n*3)+1;
            cnt++;
        }
        printf("%d\n",cnt);
    }
    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(){
	int n,ans=0;
	while(cin>>n){
		if(n==0)break;
		ans=0;
		while(1){
			if(n%2==0)n/=2;
			else n=n*3+1;
			ans++;
			if(n==1)break;
		}
		cout<<ans<<endl;
	}
}

C++: #include<cstdio>
using namespace std;
int main(void){
	int n,c;
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		c=0;
		while(n!=1){
			if(n%2==0)n/=2;
			else      n=3*n+1;
			c++;
		}
		printf("%d\n",c);
	}
	return 0;
}

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

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

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

C++: #include <stdio.h>
#include <iostream>
#include <string.h>
#include <string>
#include <math.h>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <stdlib.h>

using namespace std;

int main(void)
{
	for (int u = 0; u, 50; u++)
	{
		long long n;

		cin >> n;
		if (n == 0)
		{
			return 0;
		}

		for (long long i = 0; i < 100000; i++)
		{
			if (n == 1)
			{
				cout << i << endl;
				break;
			}
			else if (n % 2 == 0)
			{
				n = n / 2;
			}
			else
			{
				n = (n * 3) + 1;
			}
		}
	}
}

C++: #include <stdio.h>
#include <iostream>

using namespace std;

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

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


int main(){
	long long n;
	while(cin >> n,n != 0){	
		int op = 0;
		while(n != 1){
			n = n % 2 == 0 ? n/2 : 3*n+1;
			op++;
		}
		cout << op << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>

using namespace std;

int main(){

  int n;

  while(cin>>n,n){

	int cnt=0;

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

	cout<<cnt;
	
  }

}

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


}

	if(n>0){printf("%d\n",n);}
}
	return 0;
}

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

int main(void){
    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;
}