Question: That is , the program needs to take in an integer value, and run the following process using that integer. If the integer n is

That is, the program needs to take in an integer value, and run the following process using that integer.
If the integer n is even, divide it by 2 to get n /2. If n is odd, multiply it by 3 and add 1 to obtain 3n +1.
The new value that you generate (n/2 or 3n+1) is used to repeat the process until the result of the
process is 1. You should print out each of the n/2 or 3n+1 values that are calculated as intermediate
steps. You should keep track of how many steps the process takes, and output that value at the end

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 Programming Questions!