Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Hands On Database

Authors: Steve Conger

1st Edition

013610827X, 978-0136108276

More Books

Students also viewed these Databases questions

Question

Define unit testing, integration testing, and system testing.

Answered: 1 week ago

Question

Compute the total and free slack of each activity.

Answered: 1 week ago

Question

=+such as the dirigenti in Italy?

Answered: 1 week ago

Question

=+ Are there closed-shop requirements or practices?

Answered: 1 week ago