a = gets
 
numbers = [a]
 
value = 0
 
  while value == 0
    if a % 2 == 0
      a = a / 2
      numbers.push(a)
      numbers.each do |number|
        if number == a
          value = 1
          puts a
        end
      end
    else
      a = n * 3 + 1
      numbers.push(a)
      numbers.each do |number|
        if number == a
          value = 1
          puts a
        end
      end
    end
  end
