Question: In matlab script please, and thank you! The Collatz conjecture is a conjecture in mathematics that concerns a sequence defined as follows Start with any

In matlab script please, and thank you!

In matlab script please, and thank you! The Collatz conjecture is a

The Collatz conjecture is a conjecture in mathematics that concerns a sequence defined as follows Start with any positive integer n. Then each term is obtained from the previous term as follows: If the previous term is even, the next term is one half the previous term. .If the previous term is odd, the next term is 3 times the previous term plusS 1 The conjecture is that no matter what value of n, the sequence will always reach 1. For instance, starting with n-12, one gets the sequence 12, 6, 3, 10, 5, 16, 8, 4, 2, Write a MATLAB script which asks the user to provide a positive integer number (call it n). If n is not a positive integer, the program should stop and return an appropriate error message using error command in MATLAB If the input is valid, create the sequence starting with n and print the numbers on the screen until the sequence reaches 1 and stops Run your program for n-12 and report the outcome

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!