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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started