I have forgotten
my Password

Or login with:

  • Facebookhttp://facebook.com/
  • Googlehttps://www.google.com/accounts/o8/id
  • Yahoohttps://me.yahoo.com
get GPL
COST (GBP)
this unit 0.42
sub units 3.12
+
0

binomial coefficient gamma

viewed 3626 times and licensed 78 times
Computes the binomial coefficient with the given arguments.
Controller: CodeCogs

Dependents

Info

Interface

C++
Excel

Binomial Coefficient Gamma

 
intbinomial_coefficient_gammaintn
intk )
This function calculates the binomial coefficient \inline  C(n, k) directly, using the logarithm of the Gamma function, rather than recursively. \inline  C(n, k) 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

nthe first combinatorial parameter
kthe second combinatorial parameter

Returns

the binomial coefficients with parameters n and k

Authors

Lucian Bentea (August 2005)
Source Code

Source code is available when you agree to a GP Licence or buy a Commercial Licence.

Not a member, then Register with CodeCogs. Already a Member, then Login.