public static function fallingFactorial($x, int $n)
{
if ($n < 0) {
throw new Exception\OutOfBoundsException('Cannot compute rising factorial of a negative number.');
}
if ($n > $x) {
return 0;
}
$fact = 1;
while ($n > 0) {
$fact *= $x - $n + 1;
$n--;
}
return $fact;
}