3 ms·
Humans can't tell you whether this program will run forever on any particular (positive integer) input, or whether all inputs terminate. def collatz(n):
by smallnamespace 6y ago
Humans can't tell you whether this program will run forever on any particular (positive integer) input, or whether all inputs terminate.
def collatz(n):
while n != 1:
print(n)
if n % 2 == 0:
n = n // 2
else:
n = n * 3 + 1
print(1)