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

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: while True:
    n = int(input())
    if n==0: break
    count = 0
    while True:
        if n==1:
            print(count)
            break
        elif n % 2 ==0:
            n /= 2
            count +=1
        else:
            n*=3
            n+=1
            count += 1

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

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:
    n=int(input())
    
    if n==0:
        break
    
    i=0
    
    while n!=1:
        if n%2==0:
            n=n/2
        else:
            n=3*n+1
        i+=1
    
    print(i)

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

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

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

Python: def coll(n):
  cnt = 0
  while n > 1:
    if n % 2:
      n = n * 3 + 1
      cnt += 1
    while n % 2 == 0:
      n = n // 2
      cnt += 1
  return cnt

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

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

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

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

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

Python: import sys
def main():
    for line in sys.stdin:
        n = int(line)
        if n == 0:
            break

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


if __name__ == "__main__":
    main()

Python: while True:
    num = int(input())

    if num == 0:
        break

    count = 0

    while num != 1:

        if num % 2 == 0:
            num >>= 1
            count += 1
        else:
            num += num // 2 + 1
            count += 2

    print(count)

Python: #入力値0になるまで繰り返す
while True:
    num = int(input())
    if num == 0:break

#numが偶数の時は22で割り、奇数のときは3倍し1を足す
    else:
        kei = 0
        while num != 1:
            if num % 2 == 0:num /= 2
            else:
                num *= 3
                num += 1
            kei += 1
        print(kei)

Python: # coding: utf-8
# Your code here!

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

Python: # AOJ 0158: Collatz's Problem
# Python3 2018.6.18 bal4u

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: 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: # coding: utf-8
# Your code here!


    
def coll(n):    
    k=0
    while n>1:
        if n%2:
            n=n*3+1
            k+=1
        while n%2==0:
            n=n//2
            k+=1
    return k
    
while True:
    n=int(input())
    if n==0:
        break
    print(coll(n))

Python: # coding: utf-8
# Your code here!

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

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(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(f(_n, 0))

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

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

Python: #もし0のときは終了
#if文で偶数のとき、奇数の時で分ける
#結果が１になるまで繰り返し回数をカウント

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

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

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

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

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