The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 2 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
I need help figuring out the code. I'm using python language and pycharm program. I'm given
def collatz(data):
Part III: The Collatz Sequence (3 points) Define a new function named collat 2 that will create a sequence of numbers that starts with a specified value.
Initialize a list so it contains only the value passed as a parameter. Then use a while loop to extend the list using
the following process: Let n be the value currently at the end of the list. If n is even, extend the list with g, but if CSE 101 — Spring 2017 Lab #4 Page 2 n is odd, extend the list with 3 X n + 1. An unproven conjecture from number theory is that eventually the number
1 will be appended to the list, which is when the process terminates. Examples: Function Call Retum Value collatz(2) [2, 1] collatz(l5) [5, 16, 8, 4, 2, 1] collatz(l7) [17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, l]
-----------