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

Python: while True:
    n=int(input())
    if n==0:
        break
    else:
        s=0
        while True:
            if n==1:
                break
            elif n%2==0:
                n=n//2
                s+=1
            else:
                n=(n*3)+1
                s+=1
        print(s)

Python: def col(a):
    i=0
    while a!=1:
        if a%2==0:a//=2
        else:a=3*a+1
        i+=1
    return i
while True:
    a=input()
    if a!=0:print(col(a))
    else:break

Python: # Aizu Problem 00158: Collatz's Problem
#
import sys, math, os, bisect

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def collatz(n):
    steps = 0
    while n != 1:
        steps += 1
        if n % 2 == 0:
            n //= 2
        else:
            n = 3 * n + 1
    return steps


while True:
    n = int(input())
    if n == 0:
        break
    print(collatz(n))

Python: while 1:
    n = int(input())
    if n == 0:
        break

    cnt = 0
    while n != 1:
        if n % 2 == 0:
            n //= 2
        else:
            n = n * 3 + 1
        cnt += 1

    print(cnt)

Python: while 1:
    n=int(input())
    if n==0:break
    c=0
    while n!=1:
        n=n*3+1 if n%2 else n/2
        c+=1
    print(c)

Python: while True:
    n = int(input())
    if n == 0:
        break
    c = 0
    
    while n != 1:
        c += 1
        if n %2:
            n = 3 * n +1
        else:
            n = n//2
    print(c)

Python: while True:
    n = int(input())
    ans = 0
    if n == 0:
        break
    while n > 1:
        ans += 1
        if n % 2 == 0:
            n = n/2
        else:
            n = 3 * n + 1
    print(ans)

Python: while True:
    n=int(input())
    sum=0
    if n==0:
        break
    while n>1:
        if n%2==0:
            n/=2
            sum+=1
        else:
            n=3*n+1
            sum+=1
    print(sum)

Python: def f(n, t):
    if n % 2 == 0:
        n = int(n / 2)
    else:
        n = n * 3 + 1
    t += 1
    if n == 1:
        return t
    else:
        return f(n, t)


while True:
    _n = int(input())
    if _n == 0:
        break
    print(0 if _n == 1 else f(_n, 0))

Python: while True:
    n = int(input())
    if n == 0:
        break
    cnt = 0
    while n != 1:
        n = 3*n+1 if n % 2 else n//2
        cnt += 1
    print(cnt)

Python: while True:
  n = int(input())
  if n == 0: exit()
  c = 0
  while n != 1:
    c += 1
    if n % 2 == 0:
      n /= 2
    else:
      n = n * 3 + 1
  print(c)

Python: while True:
    n = int(input())
    c = 0
    if n == 0:
        break

    while n != 1:
        c += 1
        if n % 2 == 0:
            n //= 2
        else:
            n = n * 3 + 1
    
    print(c)

Python: while True:
    n = int(input());
    if n == 0:
        break;
    i = 0;
    while n != 1:
        i += 1;
        if n % 2 == 0:
            n = n / 2;
        else:
            n = n * 3 + 1;
    print(i);

Python: n=int(input())
while n!=0:
    c=0
    while n!=1:
        if n%2==0:
            n=n/2
            c=c+1
        else:
            n=n*3+1
            c=c+1
    print(c)
    n=int(input())

Python: while True:
    n = int(input())
    if n==0: break
    count = 0
    while n!=1:
        n = n//2 if n%2==0 else 3*n+1
        count += 1
    print(count)

Python: def f(x,y):
    if x==1:
        return(y)
    if x%2==0:
        return(f(x/2,y+1))
    else:
        return(f(3*x+1,y+1))

while True:
    x=int(input().strip())
    if x==0:
        break
    print(f(x,0))

Python: while True:
   x = int(input())
   if x == 0:
      break
   c=0
   while True:
      if x==1:
         break
      elif x%2==0:
         x = x//2
      else:
         x = x*3 +1
      c += 1
   print(c)

Python: while True:
    N = int(input())
    if N == 0:
        break

    ans = 0
    while N != 1:
        if N % 2 == 0:
            N = N / 2
        else:
            N = 3*N + 1
        ans = ans + 1
    print(ans)

Python: for i in range(50):
    n = int(input())
    
    if n == 0:    break
    
    i = 0
    while 1:
        if n == 1:  break
        if n % 2 == 0:
            n = n / 2
        else:
            n = n*3 + 1
        i += 1
    
    print(i)

Python: while 1:
    n=int(input())
    if n==0:break
    c=0
    while n!=1:
        if n%2:n=n*3+1 
        else:n/=2
        c+=1
    print(c)

Python: def collatz(n):
    i=0
    while n != 1:
        
        if n%2==0:
            n = n/2
            i=i+1
        else:
            n=3*n+1
            i=i+1
    return(i)
    
while True:
    n=int(input())
    if n==0:
        break
    print(collatz(n))

Python: def Collatz(n) :
    if n % 2 == 0 :
        return n // 2
    else :
        return n * 3 + 1

while True :
    n = int(input())
    if n == 0 :
        break
    
    count = 0
    while n != 1 :
        n = Collatz(n)
        count += 1
    print(count)

Python: while True:
    n=int(input())
    if n==0:
        break
    else:
        i=0
        while True:
            if n==1:
                break
            else:
                i+=1
                if n%2==0:
                    n=n//2
                else:
                    n=3*n+1
        print(i)

Python: while True:
    n=int(input())
    if n==0: break
    a=0
    while n>1:
        if n%2==0:
            n=n/2
            a+=1
        else:
            n=3*n+1
            a+=1
    print(a)

Python: def Collatz(n) :
    if n % 2 == 0 :
        return n // 2
    else :
        return n * 3 + 1

while True :
    n = int(input())
    if n == 0 :
        break
    
    count = 0
    while n != 1 :
        n = Collatz(n)
        count += 1
    print(count)

Python: while 1:
    n = int(input())
    if n == 0:
        break

    cnt = 0
    while n != 1:
        if n % 2 == 0:
            n //= 2
        else:
            n = n * 3 + 1
        cnt += 1

    print(cnt)

Python: while True:
    n = int(input())
    count = 0
    if n == 0:
        break
    
    while True:
        if n == 1:
            break
        elif n % 2 == 0:
            n = n / 2
            count += 1
        else:
            n = n * 3 + 1
            count += 1
    print(count)

Python: while True:
    n=int(input())
    if n==0:
        break
    count=0
    while n!=1:
        if n%2==1:
            n=n*3+1
        else:
            n=n//2
        count+=1
    print(count)

Python: while 1:
    n=int(input())
    if not n:break
    a=0
    while n>1:
        if n%2:
            n=3*n+1
        else:
            n//=2
        a+=1
    print(a)

Python: while True:
    n = int(input())
    if n == 0: break
    k = 0
    while n > 1:
        if n & 1:
            n = n + ((n+1)>>1)
            k += 2
        else:
            n >>= 1
            k += 1
    print(k)

Python: def a(n) :
    if n % 2 == 0 :
        return n // 2
    else :
        return n * 3 + 1

while True :
    n = int(input())
    if n == 0 :
        break
    
    ans = 0
    while n != 1 :
        n = a(n)
        ans += 1
    print(ans)

Python: #81 コラッツの予想

while 1:
    n = int(input())
    if n == 0:
        break
    
    ans = 0
    while n != 1:
        if n%2 == 0:
            n = n//2
            ans += 1
        else:
            n = n*3+1
            ans += 1
    print(ans)