Cody Bable

Generation

generate functionWed, 12 Apr 2023

create a main driver than repeatedly calls collatz() and determines the length of the returned list.

def collatz(number): if number % 2 == 0: number = number // 2 print(number) return number elif number % 2 == 1: number = 3 * number + 1 print(number) return number def main(): number = int(input('Enter a number: ')) print(collatz(number)) main()

Questions about programming?Chat with your personal AI assistant