Question: import numpy def collatz(n): list1 = [n] if n == 1 : return [1] elif n % 2 == 0 : list1.extend(collatz(n//2)) else: list1.extend(collatz(n*3+1)) return

import numpy

def collatz(n): list1 = [n] if n == 1 : return [1] elif n % 2 == 0 : list1.extend(collatz(n//2)) else: list1.extend(collatz(n*3+1)) return list1

I'm trying to write a program where I can choose the multiplier, divisors, and number.

I was able to figure out how to multiply 3 and divide 2 to the number I want, but now I want to choose my own multiplier and divisors instead of 3 and 2.

More Info: this is the collatz sequence.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!