MathPHP\Probability\Combinatorics::risingFactorial PHP Method

risingFactorial() public static method

https://en.wikipedia.org/wiki/Falling_and_rising_factorials x⁽ⁿ⁾ = x * (x + 1) * (x + 2) ... (x + n - 1)
public static risingFactorial ( number $x, integer $n ) : number
$x number
$n integer
return number
    public static function risingFactorial($x, int $n)
    {
        if ($n < 0) {
            throw new Exception\OutOfBoundsException('Cannot compute rising factorial of a negative number.');
        }
        $fact = 1;
        while ($n > 0) {
            $fact *= $x + $n - 1;
            $n--;
        }
        return $fact;
    }