def solution(num): answer = 0 while num != 1: if answer == 500: return -1 elif num % 2 == 0: num /= 2 else: # num = 3 * num + 1 도 된다 num *= 3 num += 1 answer += 1 return answer n = 626331 print(solution(n))