Question: PYTHON Help, please. Remember the Collatz function? If x is odd, then ??????????????(??)= 3???+1 but if x is even then ??????????????(??)=??/2. (remember to use //

PYTHON Help, please.

Remember the Collatz function? If x is odd, then ??????????????(??)= 3???+1 but if x is even then ??????????????(??)=??/2. (remember to use // to divide by 2) Start by writing a Collatz() function that returns the value for a given input. Test this function for all numbers from 1 to 10. Next write a Collatz2() method. This method should take in a single number and repeatedly use the Collatz() function printing out the result while the number is not one.

For example: If I say Collatz2(5) If I say Collatz2(12) Then the output should be : 5 16 8 4 2 1 Then the output should be : 12 6 3 10 5 16 8 4 2 1

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!