Jump to page content Jump to navigation

College Board

AP Central

AP Exam Reader
Siemens Awards for Advanced Placement

APAC 2010
Print Page
Home > AP Courses and Exams > Course Home Pages > Hailstone Sequence

Hailstone Sequence

by Rodney Hoffman
Occidental College
Los Angeles, California

More Nifty Assignments...

Assignment
Write a method that computes a hailstone sequence (for a given seed) and calculates its length and the highest value reached.

Do the hailstone sequence for all numbers up to 1,000. Find and report the five numbers that take the most steps and the five numbers that reach the highest value.

Background
The hailstone sequence, sometimes called the 3n+1 sequence, is defined by a function f(n):


For example, here are the hailstone sequences for the numbers 7 through 9:

7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1

8 4 2 1

9 28 14 7 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1


For more information about hailstone sequences, plus a suggestion for writing the calculation method, you can refer to chapter 6 of Owen Astrachan's A Computer Science Tapestry, 2nd ed. (page 272), available as a PDF.
Chapter 6 of A Computer Science Tapestry

Contribute
If you would like to contribute your suggestions for nifty assignments, please submit your ideas.


  ABOUT MY AP CENTRAL
    Course and Email Newsletter Preferences
  AP COURSES AND EXAMS
    Course Home Pages
    Course Descriptions
    The Course Audit
    Sample Syllabi
    Teachers' Resources
    Exam Calendar and Fees
    Exam Questions
    FAQs
  PRE-AP
    Teachers' Corner
    Workshops
  AP COMMUNITY
    About Electronic Discussion Groups
    Become an AP Exam Reader

Back to top