Question: You may use for, while, if, elseif, round, floor, and ceil Matlab commands. Other Matlab commands such as flip, mod, etc. cannot be used. HW
You may use for, while, if, elseif, round, floor, and ceil Matlab commands. Other Matlab commands such as flip, mod, etc. cannot be used. HW Problem 1: Collatz Conjecture Game Ask the user to enter a positive integer N. If N is odd, multiply it by 3 and add 1 to it. If N is even, divide it by 2. Keep repeating this procedure until N = 1. The Collatz conjecture is that for any input value N, the final result is N=1. This has not yet been proved mathematically, but no number has been found for which this is not true. Use a while loop to implement the rules described above. The program should display the intermediate values of N (as a sequence separated by commas) and also return the number of steps needed for N to become 1. Test your program with N = 3
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
