Question: Write a function which returns the next value in the Collatz sequence. To calculate the next value in the Collatz sequence given a value n:

 Write a function which returns the next value in the Collatzsequence. To calculate the next value in the Collatz sequence given a

Write a function which returns the next value in the Collatz sequence. To calculate the next value in the Collatz sequence given a value n: If the given value n is even, the next value should be n/2 o If n is odd, the next value should be 3n+1 .Ifn is not positive the function should return 0. The Collatz conjecture states that if you repeat this process for any positive integer n the sequence will eventually reach 1. It is not known whether or not this is true. . Your function should take one integer parameter. Your function should not print anything . Your function should return the next value in the Collatz sequence. * Your function MUST be named collatzStep

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!