Java program to generate the Hailstone sequence (Collatz conjecture).

This program generates the Hailstone sequence (Collatz conjecture) of a number entered by the user.
Collatz conjecture at WikiPedia: Link.
In the Collatz conjecture, to find the next number in the sequence, we divide the current number by 2 if it is even or multiply it by 3 and add by 1 if it is odd.

So the sequence for number 6 would be: 6, 3, 10, 5, 16, 8, 4, 2, 1.

Program:

Tested in Eclipse.

The following two tabs change content below.
  • Josh

    thanks i will make you i give you the credit on my work :)