P#3. Sequence. Suppose we select some initial number T, and then build the sequence of values by the following rules: Ti = T-1 for values of T.-1 even (31-1 + 1) for values of Ti-1 odd As long as you reach 1 the sequence must stop. If T-1 is odd, the next element in the sequence grows, and if it is even, the next element in the sequence decreases. With different starting values, examples of the generated sequences are: Maximum Starting value T, T, TT3.. value in the sequence 1 I 3,5,8, 4.2.1 4,2 5,8, 4, 2,1 6,3,5,8, 4, 2,1 7, 11, 17, 26, 13, 20, 10, 5, 8, 4, 2,1 If you decide not to stop, after the sequence reaches 1 the sequence enters the Infinite loop as 121212. You need to avoid this effect in your code. You don’t want an infinite loop. Write code to 1. Compute the elements of the sequence for starting values from 1 to 25. Make a plot of the starting value versus the number of elements in the sequence to get 1. E.g., if the starting To = 7, the number of elements in the sequence are 12, these are: 7, 11, 17, 26, 13, 20, 10,5,8, 4, 2, 1. An example of the plot Starting Number vs Number of Elements in Seq berotants in the sequence 0 Slangoper 2. Calculate what is the maximum value reached in the sequence for each starting value Show transcribed image text P#3. Sequence. Suppose we select some initial number T, and then build the sequence of values by the following rules: Ti = T-1 for values of T.-1 even (31-1 + 1) for values of Ti-1 odd As long as you reach 1 the sequence must stop. If T-1 is odd, the next element in the sequence grows, and if it is even, the next element in the sequence decreases. With different starting values, examples of the generated sequences are: Maximum Starting value T, T, TT3.. value in the sequence 1 I 3,5,8, 4.2.1 4,2

5,8, 4, 2,1 6,3,5,8, 4, 2,1 7, 11, 17, 26, 13, 20, 10, 5, 8, 4, 2,1 If you decide not to stop, after the sequence reaches 1 the sequence enters the Infinite loop as 121212. You need to avoid this effect in your code. You don’t want an infinite loop. Write code to 1. Compute the elements of the sequence for starting values from 1 to 25. Make a plot of the starting value versus the number of elements in the sequence to get 1. E.g., if the starting To = 7, the number of elements in the sequence are 12, these are: 7, 11, 17, 26, 13, 20, 10,5,8, 4, 2, 1. An example of the plot Starting Number vs Number of Elements in Seq berotants in the sequence 0 Slangoper 2. Calculate what is the maximum value reached in the sequence for each starting value

## Expert Answer

Answer to P#3. Sequence. Suppose we select some initial number T, and then build the sequence of values by the following rules: Ti…