← Back to List

17869번: Simple Collatz Sequence ↗

Solutions

Python 3
97 B | 97 chars
n = int(input())
ans = 0

while  n != 1:
  n = n + 1 if n % 2 else n // 2
  ans += 1

print(ans)