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

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

int main() {
    while (true) {
        int n;
        cin >> n;
        if (n == 0) break;

        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 <algorithm>
using namespace std;

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 <bits/stdc++.h>

#define loop(v, f, l) for(int v = (f), v##_ = (l); v < v##_; ++v)

using namespace std;

typedef long long int lint;
static inline int in(){ int x; scanf("%d", &x); return (x); }
static inline lint inl(){ lint x; scanf("%lld", &x); return (x); }

int memo[1000000];

int getNumOfCollatzsProcess(int num)
{
	if( num == 1 )return 0;
	if( memo[num - 1] != 0 )return memo[num - 1];
	if( num % 2 == 0 )return 1 + getNumOfCollatzsProcess(num / 2);
	return 1 + getNumOfCollatzsProcess(num * 3 + 1);
}

int main()
{
	int n;
	while( true )
	{
		n = in();
		if( n == 0 )break;
		printf("%d\n", getNumOfCollatzsProcess(n));
	}
	return (0);
}

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

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

	return 0;
}

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

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

C++: #include<cstdio>

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

	}
	return 0;

}

C++: #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 <stdio.h>
int  main()
{
  int a,cou;
  while(1){
    scanf("%d",&a);
    if(a==0)break;
    cou=0;
    while(a!=1){
      if(a%2==0){
	a=a/2;
	cou++;
      } else {
	a=a*3+1;
	cou++;
      }
    }
    printf("%d\n",cou);
  }
  return 0;
}

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

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>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

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

C++: #include <iostream>
using namespace std;
#define rep2(x,from,to) for(int x=(from);x<(to);++(x))
#define rep(x,to) rep2(x,0,to)
int main(){
	int n;
	while(cin >> n, n) {
		int ret = 0;
		while(1) {
			if(n==1) break;
			if(n%2==0) {
				n/=2;
				ret++;
			} else {
				n = n*3+1;
				ret++;
			}
		}
		cout << ret << endl;
	}
	return 0;
}

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

C++: #include <iostream>

using namespace std;

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;
	}
	return (0);
}

C++: #include <iostream>

using namespace std;

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

int main()
{
	solve();
	return(0);
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <limits>
using namespace std;
int main(void) {
	for (;;) {
		int cnt = 0,buf;
		cin >> buf;
		if (!buf)return 0;
		for (; buf != 1;) {
			buf = buf % 2 ? buf / 2 : buf * 3 + 1;
			cnt++;
		}
		cout << cnt << endl;
	}
}

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

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

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&&((p.first-1)/3)%2) {
            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 <stdio.h>
using namespace std;

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

	return 0;
}