Answered step by step
Verified Expert Solution
Link Copied!

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

3rd Edition

978-1119907466

More Books

Students also viewed these Databases questions

Question

Write each rational expression in lowest terms. r2 r 6 r2 + r - 12

Answered: 1 week ago

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago