Go: // AOJ Collatz's Problem :http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0158

package main

import (
	"fmt"
)

func main() {
	for {
		var n int

		fmt.Scanf("%d", &n)

		if n == 0 {
			break
		}

		count := 0
		for n != 1 {
			if n%2 == 0 {
				n /= 2
			} else {
				n = n*3 + 1
			}
			count++
		}
		fmt.Println(count)
	}
}

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

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

C++: #include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

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

C++: # include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <unordered_map>

using namespace std;
using LL = long long;

constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;

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

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define INF 1<<30

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

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	int n;
	while(true){
	cin>>n;
	if(n==0)
		break;
	int i=1;
	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(){
   int n,y;

   while(1){
	int con=0;

	cin >> n;
	if(n == 0) break;
	y = n;

	while(1){
		if(y == 1) break;

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

		con++;

	}

	cout << con << endl;

   }

   return 0;

}

C++: #include<stdio.h>
#include<iostream>
#include<list>
#include<map>
#include<vector>
#include<algorithm>
#include<string.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << x << endl;
using namespace std;

int main(){
    int x, count;

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

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

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

}

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

using namespace std;

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

int main() {
	int n, ans;

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

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

int collatz(int n);

int main(void){
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    cout<<collatz(n)<<endl;
  }
  return 0;
}

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

C++: #define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

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

int main() {
	int n;
	while (cin >> n && n) {

		int ans = 0;
		while (n != 1) {
			n = re(n);
			ans++;
		}

		Cout(ans);
	}
}

C++: #include <iostream>
#include <memory>
#include <memory.h>
#include <cmath>
#include <fstream>
#include <cmath>
#include <numeric>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <sstream>
#include <cstdlib>
#include <cassert>
#include <cstdio>
#include <map>
#include <iomanip>
#include <list>
#include <cctype>
#include <algorithm>
#include <complex>
#define USE_MATH_DEFINES
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)
using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 29;
const double EPS = 1E-10;

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

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;
	}
	
}

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

int main(void){
	int n;

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

		cout<<ans<<endl;
	}

	return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

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

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

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

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