Does the following terminate for all n?
def foo(n):
if n <= 1:
return
elif n & 1:
return foo(3*n+1)
else:
return foo(n//2)