Empirical Lab Repository

Title: Repetition and the Hailstone Sequence

Author: Dave Reed, Creighton University, davereed@creighton.edu

Possible Courses: CS1

Empirical Concepts Introduced: simulation, analytical reasoning

Computer Science Concepts Used: class use, loops, counters, input/output, arithmetic operations

Summary: This assignment introduces an unsolved problem in mathematics: determining whether every "hailstone sequence" terminates in a loop. While it has been shown that this termination property holds for all starting numbers up to 1.2 trillion, it has not been proven for all numbers. For this assignment, students will write a program that generates the hailstone sequence starting with a user-specified number. The program should display the sequence, along with its length. This program demonstrates to the student that programs can be developed as tools for studying the behavior of complex problems. After completing the program, the student required to analyze its behavior and answer several questions concering the sequence.

This program utilizes several common control structures and tools, including a loop to iterate over the sequence, a conditional to differentiate between odd and even numbers, and a counter to keep track of the length of the sequence.

Variations: If desired, this assignment could be generalized to check an entire range of numbers to see if the hailstone sequence always terminates. For example, the user might be prompted for low and high numbers in the range (say, 1 and 10,000). Then, the program would generate a hailstone sequence starting with each number in the range, and verify that each terminates in a loop.