Question: I was able to use only a single divisor, but I want to make it work with a list of divisors such as [2, 3]

I was able to use only a single divisor, but I want to make it work with a list of divisors such as [2, 3] in Python. For example, I was able to divide 27 with 2, but now I want to divide it with 2 and 3. But I'm not really sure how to do it. By the way, this is the Collatz Conjecture Sequence. I really appreciate your help have a great day!

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

if __name__=="__main__": n=int(input("Enter any positive integer N: ")) multiplier=int(input("Enter the multiplier: ")) divisor=int(input("Enter the divisor: ")) print(" ",collatz(n,multiplier,divisor))

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!