Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This needs to be done in Matlab Code. P#2. Sequence. Suppose we select some initial number X and then build the sequence of values by
This needs to be done in Matlab Code.
P#2. Sequence. Suppose we select some initial number X and then build the sequence of values by the following rules i-1 for 3X-1 +1 forXi-1 odd If X._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 16 842 1 After the sequence reaches 1 it enters the infinite loop 1 4 2 142 1... 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 0 2,1 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 6 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 1Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started