Question: Help me to solve this python problem! 3 . x + 1 but if x is even Remember the Collatz function? If x is odd,
Help me to solve this python problem!
3 . x + 1 but if x is even Remember the Collatz function? If x is odd, then colla tz(x) then collat2(x) = x/2. (remember to use//todivide by 2) Start by writing a Collatz() function that returns the value for a given input. this function for all numbers from 1 to 10. Test 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 (12) Then the output should be: If I say Collatz2(5) Then the output should be 12 6 16 8 4 2 10 16 4 2 1 Once you know it is working, run your method on the number n 27 and see how long it takes to get to 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
