Question: Please use Program C to slove those problems. Thank you! Question 4: Iteration Write a program that reads in an integer and outputs the collatz
Please use Program C to slove those problems. Thank you!
Question 4: Iteration
Write a program that reads in an integer and outputs the collatz sequence for that number (https://en.wikipedia.org/wiki/Collatz_conjecture) with each output on its own line. Sound familar?
Example Input:
40
Example Output:
40 20 10 5 16 8 4 2 1
Question 5: Recursion
Solve the same collatz problem as above, but this time you must use recursion, no loops allowed. If you use a for or while loop anywhere in this program, you will receive a zero for this assignment.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
