Question: Please solve in python! A hailstone sequence is an infinite sequence that is generated recursively by the following rule: b 1 = S , b

Please solve in python!
A hailstone sequence is an infinite sequence that is generated recursively by the following rule: b1=S,bn+1={12bnifbniseven3bn+1ifbnisodd
where the positive integer S is the seed value. This sequences name is inspired by the behavior of its values, which typically ascend and descend erratically like hailstones in a strong storm.
(a) Choose any four seed values less than 25 and print the first 30 terms of the corresponding
hailstone sequences. Do you notice any patterns in the behavior of these values as each sequence progresses? Print a statement that precisely describes your observations.
(b) Write a Python function that performs the following tasks:
Accept a seed integer as input.
Print True if the pattern you observed in part (a) appears within the first 300 terms of the corresponding hailstone sequence. If not, print False.
If True was printed, also print the number of terms that had to be checked before the
predicted pattern occurred.
Run your function with the seed integers S=157,1011,3453,5722.
(c) Using plt.plot(), graph the following partial hailstone sequences.
(i) S =103 with n 88.
(ii) S =385 with n 33.
(iii) S =512 with n 10.
(iv) S =1758 with n 149.
Note: You may need to use plt.show() after each plotting command to separate the graphs into different images.
 Please solve in python! A hailstone sequence is an infinite sequence

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!