Question: Using MATLAB. 1. Write a script that will take the starting value as an input and test whether it reaches 1. (a) If it takes

Using MATLAB.

1. Write a script that will take the starting value as an input and test whether it reaches 1.

(a) If it takes more than 100,000 steps, the script should stop and print It takes more than 100,000 steps to test the conjecture.

(b) If there exists 1 < i < j < 100, 000 such that mi = mj , the script should stop and print Collatz conjecture is false and m is the counter example! (m should be the starting value). (c) If it reaches 1 in less than 100,000 steps, the script should stop and print Collatz conjecture is true for m and it takes n many steps to reach 1. (m should be the starting value and n should be the minimum number of steps needed to reach 1 from m). Also, create a line plot of current step(i) vs. current number(mi). The figure should have markers and appropriate title, x-axis and y-axis names.

2. Write a script that will take a number, k, as an initial input then find the first number that will take more than or equal to k many steps to reach 1. For example, if k = 111, then the answer should be 27.

(a) If the starting value needs to be bigger than 100,000, the script should stop and print All the starting values up to 100,000 take less than k steps to reach 1 (k should be the step size).

(b) If there is an answer, m, smaller than 100,000, the script should stop and print m is the first starting value that takes at least k steps to reach 1 (m should be the answer and k should be the step size). Also, create a bar graph of step size(k) vs. Number of starting values needing k steps for all starting values up to m. The bar graph should have appropriate title, x-axis and y-axis names.

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