while X != 1: print(X, end=' ') if X % 2 == 0: X = X // 2 else: X = 3 * X + 1 print(1)