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:
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 and print the first 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 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
c Using pltplot graph the following partial hailstone sequences.
i S with n
ii S with n
iii S with n
iv S with n
Note: You may need to use pltshow after each plotting command to separate the graphs into different images.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
