Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A Hailstone series is defined as follows: start with any integer value greater than 0 , say x . If x is even, then the

A Hailstone series is defined as follows: start with any integer value greater than 0, say x. If x is even, then the next value in the series is x/2; if x is odd, then the next value in the series is 3x +1. Now apply the same rules to create the next value in the series, and so on. The name Hailstone comes from the property that the values in such a series alternate between going up and down (up for odd values and down for even values.)
For instance, here is the Hailstone series generated from starting value 17:
17,52,26,13,40,20,10,5,16,8,4,2,1
Note that if a Hailstone series ever reaches the value 1, then the next value generated is 4, the next is 2, and the next is 1 again. Thus, when a Hailstone series reaches 1, then it has converged in the sense that the rest of the series is 4,2,1,4,2,1,....
The Hailstone series is the subject of a long-standing mathematical open question: given an arbitrary positive integer as a starting value, will the resulting Hailstone series converge as just described? For all positive integers of size at most 1.2x1012, it is known that the series does converge. To date, however, there is no formal proof that all such series must converge. (There is an interesting and readable article about the Hailstone series in the January 1984 issue of Scientific American .)
For this assignment, you will write a program that allows users to enter a starting value from which the program computes and outputs the corresponding Hailstone series (stopping with 1 if it ever reaches 1). After the initial program works, there are a number of other requirements to change it slightly, one step at a time, as explained below.

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

Students also viewed these Databases questions