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 <algorithm>

using namespace std;

int count;

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


int main(){
  int n;


  while(true){
    cin >> n;
    if(!n) break;
    cout << collatz(n, 0) << endl;
  }

  return 0;
}

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


}

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

C++: //21
#include<iostream>

using namespace std;

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

C++: #include<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 <bits/stdc++.h>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

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

const double eps = 1e-10;
const double pi  = acos(-1.0);
const double inf = (int)1e8;

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

C++: #include <iostream>
#include <vector>
#include <algorithm>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

typedef long long ll;

int main()
{
	ll a;
	while(cin >> a && a)
	{
		ll count = 0;

		while(true)
		{
			if(a == 1) break;

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

		cout << count << endl;
	}
	return 0;
}

C++: /*
	0158:Collatz's Problem
*/
#include	<iostream>

using namespace std;

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

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

int main(){

  long long int n;

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

    cout << count << endl;
  }
}

C++: #include <iostream>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <stdlib.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    while(n!=0){
        int count=0;
        while(n!=1){
            if(n%2==0){
                n = n/2;
                count++;
            }else{
                n = 3*n+1;
                count++;
            }
            if(n==1)break;
        }
        cout << count << endl;
        cin >>n;
    }
    return 0;
}

C++: 
#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 <cstdio>
using namespace std;

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

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

int main(){

  int n;
  int count;

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

    count=0;

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


  return 0;
}

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

using namespace std;

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

    cout << ans << endl;
  }

  return 0;
}

C++: 
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0158

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int calc(int n){
	return (n % 2 == 0) ? n/2 : 3*n+1 ;
}

int main()
{
	int N;

	while(cin >> N && N)
	{
		int tmp=N, cnt=0;

		while(true)
		{	
			if(tmp == 1){ break; }
			cnt++;
			tmp = calc(tmp);
		}

		cout << cnt << endl;
	}

	return 0;
}

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

C++: #include<stdio.h>

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

int main()
{

    long long int aa,bb,a,b,t,i,max;

    while(~scanf("%lld",&aa) && aa){
        printf("%lld\n",count(aa));
    }
    return 0;
}

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

using namespace std;

int main()
{

  while(1){
    int num;
    cin>>num;
    if(num == 0){
      break;
    }

    int ans = 0;
    while(1){

      if(num % 2 == 0){
        num = num / 2;
      }
      else{
        num = 3 * num + 1;
      }

      ++ans;

      if(num == 1){
        break;
      }
    }

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

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

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

int count(int n);

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

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

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

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

C++: #include<stdio.h>
#include<cstdio>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
    int a,b;
    int n=0;
    while(scanf("%d",&n)!=EOF)
    {
        int cnt=0;
        if(n==0)break;
        for(;;)
        {
            if(n%2==0)
            {
                //cout<<"ok"<<endl;
                n=n/2;
                cnt++;
            }
            else if(n%2!=0)
            {
                //cout<<"3ok"<<endl;
                n=n*3;
                n+=1;
                cnt++;
            }
            if(n==1)break;
        }
        cout<<cnt<<endl;
    }
    return 0;
}