![]() |
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): GMP
Parameters: 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. PHP
Output Binomial Coefficient C(6, 2) is: 15
Program 2: The following program demonstrates the gmp_binomail() function. PHP
Output: k value must be greater than 0
Reference: https://www.php.net/manual/en/function.gmp-binomial.php |
Reffered: https://www.geeksforgeeks.org
PHP |
Related |
---|
![]() |
![]() |
![]() |
![]() |
![]() |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 13 |