Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- l = input("Enter a number: ")
- l = int(l)
- i = []
- def collatz(n):
- print(i) # <= print here
- if n==1:
- return i
- if n%2 == 0:
- n = n/2
- i.append(n)
- return collatz(n)
- else:
- n = ((n*3) + 1) / 2
- i.append(n)
- return collatz(n)
- print(i)
- collatz(l)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement