Hailstone sequence
The Hailstone sequence of numbers can be generated from a starting positive
integer, n
by:
- If
n
is1
then the sequence ends - If
n
iseven
then the nextn
of the sequence= n/2
- If
n
isodd
then the nextn
of the sequence= (3 * n) + 1
The (unproven) Collatz conjecture is that the hailstone sequence for any starting number always terminates.
The hailstone sequence is also known as hailstone numbers (because the values are usually subject to multiple descents and ascents like hailstones in a cloud), or as the Collatz sequence.
Test
{{test}}Console output