Hailstone

<?php

/**
 * hailstone
 *
 * Calculates a hailstone sequence.
http://en.wikipedia.org/wiki/Collatz_conjecture
 *
 * @version 0.3
 * @author Contributors at eXorithm
 * @link https://www.exorithm.com/algorithm/view/hailstone Listing at eXorithm
 * @link https://www.exorithm.com/algorithm/history/hailstone History at eXorithm
 * @license https://www.exorithm.com/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;
}

?>