![]() |
VOOZH | about |
The gmp_binomial() function is an inbuilt function in PHP that is used to calculate the binomial coefficients. The binomial coefficient, often denoted as "n choose k" or "C(n, k)", represents the number of ways to choose "k" elements from a set of "n" distinct elements without regard to the order.
Syntax:
gmp_binomial(GMP|int|string $n, int $k): GMPParameters: This function accepts two parameters that are described below.
Return Value: The gmp_binomial() function returns the coefficient of the numbers c(n, k) ;
Program 1: The following program demonstrates the gmp_binomail() function.
Output
Binomial Coefficient C(6, 2) is: 15Program 2: The following program demonstrates the gmp_binomail() function.
Output:
k value must be greater than 0 Reference: https://www.php.net/manual/en/function.gmp-binomial.php