Description
The Collatz sequence is generated with the following algorithm.
1. Start with an integer n.
2. If n is even, divide by 2.
3. If n is odd, multiply by 3 and add 1.
4. Repeat this process with the new value of n, terminating when n = 1.
For example, starting with n = 11, the following sequence of numbers will be generated: 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1.
Write a MIPS program that prompts the user to enter the starting value n and prints the Collatz sequence.
An example run is shown below:
Enter starting n = 22
Bonus: Implement a recursive version of the Collatz program without using any loops.
Chitra Jerry –
Work was finished long before due and tutor was considerate and engaging. Perfect!
Reyes Flores –
Tutor wrote it quickly and effectively. Great solution.
Patrick Lorenz –
Second time coming to this website for a paper and it worked out great.