Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

gmp_binomial

Description

The gmp_binomial of GMP for PHP calculates a binomial coefficient.

Syntax

gmp_binomial(
    GMP|int|string $n,
    int $k
): GMP

Parameters

n

A GMP object, an int or a numeric string.

k

An int.

Return

Returns the binomial coefficient C(n, k), as a GMP object.

Examples

1 · n k · GMP

<?

$n = 4;
$k = 2;

$n = gmp_init($n);

$return = gmp_binomial($n, $k);

var_dump($return);

?>
object(GMP)#2 (1) {
  ["num"]=>
  string(1) "6"
}

2 · n k · int

<?

$n = 4;
$k = 2;

$return = gmp_binomial($n, $k);

var_dump($return);

?>
object(GMP)#1 (1) {
  ["num"]=>
  string(1) "6"
}

3 · n k · string

<?

$n = "4";
$k = 2;

$return = gmp_binomial($n, $k);

var_dump($return);

?>
object(GMP)#1 (1) {
  ["num"]=>
  string(1) "6"
}
HomeMenu