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 to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources