Question: CODE NEEDS TO BE IN PYTHON. OLA 5: Collatz Sequence Function 12 17 34 Due: Fri Oct 19, 2018 by 11:59 PM-may be tumed in

CODE NEEDS TO BE IN PYTHON.
 CODE NEEDS TO BE IN PYTHON. OLA 5: Collatz Sequence Function

OLA 5: Collatz Sequence Function 12 17 34 Due: Fri Oct 19, 2018 by 11:59 PM-may be tumed in until Oct 26 by 1159 PM with reduced points (per Open Lab- Project guidance found in the course syllabus) Assignment id: ola5 Assignment type: Project Required Files: ola5.py, myout.log Lab description: In this you will explore the Collatz mathematical sequence. This sequence eventually converges to the value 1, regardless of the initial input Requirements: 1. Write a function named collatz0 that has one parameter named number. If number is . even, then collatz0) should print number //2 and retum this value (integer divison). . odd, then collatz) should print and retum 3 number + 1 2. Write a program that lets the user type in an integer, and keeps calling the collatz() function on subsequent results until the function returns the value 1 Hints: . You must use a loop that exits the program only when the returned value is 1 . Remember to convert the returm value from input() to an integer with the int() function otherwise, it will be a string value. An integer number is even if number % 2 1+0, and it's odd if number % 2 : . 1. A sample output of the program should look something like this: Enter number: 3 10 16

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!