Hailstone

<?php

/**
 * hailstone
 *
 * Calculates a hailstone sequence.
http://en.wikipedia.org/wiki/Collatz_conjecture
 *
 * @version 0.3
 * @author Contributors at eXorithm
 * @link /algorithm/view/hailstone Listing at eXorithm
 * @link /algorithm/history/hailstone History at eXorithm
 * @license /home/show/license
 *
 * @param number $number number to start with
 * @return array
 */
function hailstone($number=17)
{
	$result = array();
	
	while ($number > 1) {
		$result[] = $number;
		if ($number & 1)
			$number = 3 * $number + 1;
		else
			$number = $number / 2;
	}
	
	$result[] = $number;
	
	return $result;
}

?>