Question: C++ 3B/mod reso. CSCI 1300-F18 (117 unread) pho/8393B/mod Problems Set: Write a program for each of the following pro first in Cloud9. For each of

C++  C++ 3B/mod reso. CSCI 1300-F18 (117 unread) pho/8393B/mod Problems Set: Write

3B/mod reso. CSCI 1300-F18 (117 unread) pho/8393B/mod Problems Set: Write a program for each of the following pro first in Cloud9. For each of problem, you are required to submit a cpp file with your function and a mainO function with 2 tests cases. Write a function collatzStep which takes a single integer argument and returns an integer. The return value should be the next value in the Collatz sequence based on the value of the input parameter. If the given value n is even, the next value should be n/2. If n is odd, the next value should be 3n+1 .If the given value is not positive the function should return 0. Your function should be named collatzStep . Your function takes one input argument: an integer number . Your function must return an integer, as specified above Examples: 1. If n is 4, the next number in the Collatz sequence is 2 2. If n is 7, the next number in the Collatz sequence is 22 3. If n is -5, the function should return 0

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!