I\'m trying to write a Collatz program using the guidelines from a project found at the end of chapter 3 of Automate the Boring Stuff with Python. I\'m using python 3.
3.
def cyclic(number): if number % 2 == 0: if number // 2 == 1: print(1) else: print(number//2) cyclic(number // 2) else: print((number * 3) + 1) cyclic((number * 3) + 1) print("Enter a number:") try: n = int(input()) cyclic(n) except ValueError: print("Unvalied value")
The simplest one