The Hailstone sequence of numbers can be generated from a starting positive integer, &nbsp; n &nbsp; by:
* &nbsp; If &nbsp; n &nbsp; is &nbsp; &nbsp; '''1''' &nbsp; &nbsp; then the sequence ends.
* &nbsp; If &nbsp; n &nbsp; is &nbsp; '''even''' then the next &nbsp; n &nbsp; of the sequence &nbsp; <big><code> = n/2 </code></big>
* &nbsp; If &nbsp; n &nbsp; is &nbsp; '''odd'''  &nbsp; then the next &nbsp; n &nbsp; of the sequence &nbsp; <big><code> = (3 * n) + 1 </code></big>


The (unproven) [[wp:Collatz conjecture|Collatz conjecture]] is that the hailstone sequence for any starting number always terminates.


The hailstone sequence is also known as &nbsp; ''hailstone numbers'' &nbsp; (because the values are usually subject to multiple descents and ascents like hailstones in a cloud).

This sequence is also known as the &nbsp; ''Collatz sequence''.


;Task:
# Create a routine to generate the hailstone sequence for a number.
# Use the routine to show that the hailstone sequence for the number 27 has 112 elements starting with <code>27, 82, 41, 124</code> and ending with <code>8, 4, 2, 1</code>
# Show the number less than 100,000 which has the longest hailstone sequence together with that sequence's length.<br> &nbsp;  (But don't show the actual sequence!)


;See also:
* &nbsp; [http://xkcd.com/710 xkcd] (humourous).
<br><br>
