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
New on Educative
Learn any Language for FREE all September 🎉
For the entire month of September, get unlimited access to our entire catalog of beginner coding resources.
🎁 G i v e a w a y
30 Days of Code
Complete Educative’s daily coding challenge every day in September, and win exciting Prizes.

Free Resources