(Solved) : P 3 Sequence Suppose Select Initial Number T Build Sequence Values Following Rules Ti Ti 1 Q41407373 . . .

I need this code in python language!!!

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

5,8, 4, 2,1 6,3,5,8, 4, 2,1 0000 7, 11, 17, 26, 13, 20, 10, 5, 8, 4, 2,1 26 If you decide not to stop, after the sequence rea

P#3. Sequence. Suppose we select some initial number T, and then build the sequence of values by the following rules: Ti = -Ti-1 for values of Ti-1 even Ti = (3Ti-1 + 1) for values of Ti-1 odd As long as you reach 1 the sequence must stop. If Ti-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,T2 T3 .. value in the sequence 2,1 3,5,8, 4, 2,1 4,2,1 5,8, 4, 2,1 6,3,5,8, 4, 2,1 0000 7, 11, 17, 26, 13, 20, 10, 5, 8, 4, 2,1 26 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 Number of Elements in the sequence 15 20 Starting Number 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 = -Ti-1 for values of Ti-1 even Ti = (3Ti-1 + 1) for values of Ti-1 odd As long as you reach 1 the sequence must stop. If Ti-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,T2 T3 .. value in the sequence 2,1 3,5,8, 4, 2,1 4,2,1
5,8, 4, 2,1 6,3,5,8, 4, 2,1 0000 7, 11, 17, 26, 13, 20, 10, 5, 8, 4, 2,1 26 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 Number of Elements in the sequence 15 20 Starting Number 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…