Dit is de code:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Permutaties en combinaties</title>
</head>
<body>
<?php
$getal1 = $_POST ['getal1'];
$faculteit = 1;
$n = $_POST ['n'];
$r = $_POST ['r'];
for ($x=$getal1; $x>=1 ; $x--) {
$faculteit = $faculteit * $x;
}
if (strlen($getal1) > 0) {
echo "De faculteit van " . $getal1 . " is " . $faculteit;
}
define (NaN,acos(1.01));
function nCr($n,$r){
if ($r > $n)
return NaN;
if (($n-$r) < $r)
return nCr($n,($n-$r));
$return = 1;
for ($i=0;$i < $r;$i++){
$return *= ($n-$i)/($i+1);
}
return $return;
}
?>
</body>
</html>