Published on 21 Dec 2010. Tagged with php, algorithmicadvent.
function nChooseK($n, $k)
{
$top = 1;
$bottom = 1;
for ($i = 0; $i < $k; $i++) {
$top *= $n - $i;
$bottom *= $i + 1;
}
return $top / $bottom;
}
var_dump(nChooseK(6, 4));