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

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

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


int main(int argc, const char * argv[]) {
    
    while (true) {
        int n;
        cin >> n;
        if(n==0){
            break;
        }
        
        int count=0;
        while (true) {
            if(n == 1){
                break;
            }
            else if(n % 2 == 0){
                n /= 2;
            }
            else{
                n = 3*n + 1;
            }
            
            count++;
        }
        
        cout << count << endl;
    }
    
    return 0;
}

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

int main(void){
	while (true){
		int in, ct = 0;
		cin >> in;
		if (in == NULL){
			break;
		}
		while (true){
			if (in == '0'){
				ct = NULL;
				break;
			}
			if (in % 2 == 0){
			in = in / 2;
				ct++;
			}
			else {
				in = in * 3 + 1;
				ct++;
			}
			if (in == 1){
				break;
			}
		}
	cout << ct << endl;
	}
}

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

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

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

    int i;
    for(i = 0; n != 1; i++) {
      if(n % 2 == 0) {
	n /= 2;
      } else {
	n = n * 3 + 1;
      }
    }
    cout << i << endl;
  }
  return 0;
}

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

using namespace std;

int main() {
  while( 1 ) {
    int n;  
    cin >> n;
    if( !n ) { return EXIT_SUCCESS; }

    int i;
    for( i = 0; n != 1; i++ ) {
      n = ( n % 2 ? n * 3 + 1 : n / 2 ); 
    }
    cout << i << endl;
  }
}

C++: 
#include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<complex>
using namespace std ;
typedef vector<int> vi ;
typedef vector<vi> vvi ;
typedef vector<string> vs ;
typedef pair<int, int> pii; 
typedef long long ll ;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()


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

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

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

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

C++: #include <iostream>

using namespace std;

int main(){

	int n;
	int ans;

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

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

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

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

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

int main()
{
	int n, count;
	while (cin>>n, n) {
		count = 0;
		while (n != 1) {
			count++;
			if (n&1) n = 3*n+1;
			else n /= 2;
		}
		cout<<count<<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 % 2) 
                n = 3 * n + 1;
            else
                n /= 2;
            cnt++;
        }
        cout << cnt << 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(){
	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>
#include<string>
#include<iostream>
#include<algorithm>

using namespace std;

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

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

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

int main() {
	int n;
	while(n=in()){
		cout<<col(n)<<endl;
	}
	return 0;
}

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

int main(){
	int n,a;

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

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

int main()  {

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