NCR

This algorithm finds all the possible combination of the value n and r.



									function Factorial($number)
{
	if ($number < 0)
		return -1; //Error

	$result = 1;

	for ($i = 1; $i <= $number; $i++)
		$result *= $i;

	return $result;
}

function NCR($n, $r)
{
	return Factorial($n) / (Factorial($r) * Factorial($n - $r));
}
								


Example

									$ncr = NCR(5, 2);
								


Output

									10