Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Must be in python CSCI 1170 (Barbosa F18) OLA 5: Collatz Sequence Function 13 17 26 7 22 Due: Fri Oct 19, 2018 by 11:59

Must be in python image text in transcribed
CSCI 1170 (Barbosa F18) OLA 5: Collatz Sequence Function 13 17 26 7 22 Due: Fri Oct 19, 2018 by 11:59 PM -may be turned in until Oct 26 by 11:59 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 wil explore the Collatz mathematical sequence. This sequence eventually converges to the value 1, regardless of the initial input. Requirements: 1. Write a function named collatz) that has one parameter named number. If number is even, then collatz() should print number // 2 and return this value (integer divison). . odd, then collatz() should print and return 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 return 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 e e . 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_2

Step: 3

blur-text-image_3

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

Business Process Driven Database Design With Oracle PL SQL

Authors: Rajeev Kaula

1st Edition

1795532386, 978-1795532389

Students also viewed these Databases questions

Question

6. The cost of the training creates a need to show that it works.

Answered: 1 week ago