What is gmp_binomial in PHP?

gmp_binomial is a function in PHP that calculates the binomial coefficient.

Syntax


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

Parameters

  • n: can be a numeric string, GMP object, or type int.

  • k: number of combinations.

Return value

The function returns the binomial coefficient C(n,k)C(n,k).

Code

<?php
$result = gmp_binomial('4',2);
echo "The binomial coefficient of the result is ".$result;
?>

Output


The binomial coefficient of the result is 6

Free Resources