Question: Solve for MATLAB P#2. Sequence. Suppose we select some initial number X and then build the sequence of values by the following rules xX1 forXi-1

Solve for MATLAB  Solve for MATLAB P#2. Sequence. Suppose we select some initial number

P#2. Sequence. Suppose we select some initial number X and then build the sequence of values by the following rules xX1 forXi-1 even 3x-1+1 forKi-1 odd If Xi-1 is odd, the next element in the sequence grows, and if it is even, the next element in the sequence decreases. For example, with the starting X 17 we have the sequence 17 52 26 13 40 20 10 5 168421 After the sequence reaches 1 it enters the infinite loop 1 42 14 21... Your task is for given numbers to calculate how many steps are necessary to come to 1. For the starting X 17, the number of steps to get to 1 is 12 (i.e., one less the number of sequence elements) Starting value, Number of Steps to reach one 0 3, 10, 5, 16, 8, 4, 2, 1 4, 2,1 5, 16, 8,4, 2,1 6, 3, 10, 5, 16, 8, 4, 2, 1 4 Write code to compute the elements of the sequence for starting values from 1 to 50. Make a plot of the starting value versus the number of steps required to reach 1

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!