Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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