Question: Problem 4 : Hailstone Sequences In mathematics, a hailstone sequence is a sequence creates as follows: Select a starting value for the sequence. If a

Problem 4: Hailstone Sequences
In mathematics, a hailstone sequence is a sequence creates as follows:
Select a starting value for the sequence.
If a particular term in the sequence is equal to n, then the next term will be equal to n/2 if n is even, and will be
equal to 3n +1 if n is odd.
The sequence continues until reaching a term that is equal to 1.
For example, the hailstone sequence beginning with 12 is: 12,6,3,10,5,16,8,4,2,1
It is widely believed that any starting value will result in a sequence that eventually reaches 1, but this has not been proven
to be true.
Use while loops to calculate the hailstone sequences beginning with 15,17, and 22, storing the sequences (in order) in
lists named hs15, hs17, and hs22. This will require three separate (but nearly identical) loops. The elements stored in
the lists should be integers (as opposed to floats). Print the contents of the three lists.

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!