-
- from: CC Small College Computing Conference 4th Programming Contest
-
- In the January 1984 issue of Scientific American, an interesting sequence of number known as hailstone sequence of numbers known as a hailstone series was described. The series is formed by generating the next number based on the number just prior to it. If the previous number was even, the next number in the series is half of it. If the previous number was odd, the next number is three times it plus one. Although the series goes up and down, it eventually settles into a steady state of 4, 2, 1, 4, 2, 1,... For example, starting at 21, the hailstone serries is 21, 64, 32, 16, 8, 4, 2, 1, 4, 2, 1, ... For 21, it required five steps before the steady state was reached.
- Write a program that computes how many steps will be necessary before the steady state is reached in the hailstone series beginning at a given number.