FUNCTION
binomial_coefficient_gamma
Computes the binomial coefficient with the given arguments.
Interface
#include <codecogs/maths/combinatorics/arithmetic/binomial_coefficient_gamma.h>
using namespace Maths::Combinatorics::Arithmetic;
This function calculates the binomial coefficient directly, using the logarithm of the Gamma function, rather than recursively.
is the number of distinct combinations of k objects chosen from a set of n distinct objects. A combination is like a set, in that order does not matter. The computed expression has the following form:
This coefficient represents the number of distinct combinations of k objects chosen from a set of n distinct objects. The advantage in using this function is that large values of n and k may be given, without the fear of arithmetic overflow during the intermediate calculations. This is possible with the use of the logarithm of the Gamma function.
Example:
#include <codecogs/maths/combinatorics/arithmetic/binomial_coefficient_gamma.h>
#include <iostream>
int main()
{
for (int i = 0; i <= 6; i++)
{
std::cout << "C(6, " << i << ") = ";
std::cout << Maths::Combinatorics::Arithmetic::binomial_coefficient_gamma(6, i);
std::cout << std::endl;
}
return 0;
}
Output:
C(6, 0) = 1
C(6, 1) = 6
C(6, 2) = 15
C(6, 3) = 20
C(6, 4) = 15
C(6, 5) = 6
C(6, 6) = 1
References
SUBSET, a C++ library of combinatorial routines, http://www.csit.fsu.edu/~burkardt/cpp_src/subset/subset.html
Parameters
Returns
Interactive Calculator
Computing…
Set a range above first to export a graph.