Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.
image text in transcribed
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

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

SQL Antipatterns Avoiding The Pitfalls Of Database Programming

Authors: Bill Karwin

1st Edition

1680508989, 978-1680508987

More Books

Students also viewed these Databases questions

Question

Write down the circumstances in which you led.

Answered: 1 week ago