Crystallography/Mathematics/GammaFunction.cs
/// <summary>
/// Returns a binomial coefficient of n and k as a double precision number
/// </summary>
/// <param name="n"></param>
/// <param name="k"></param>
/// <returns></returns>
Returns a binomial coefficient of n and k as a double precision number
Returns a binomial coefficient of n and k as a double precision number
public static double BinomialCoefficient(int n, int k)
        {
            if (k < 0 || k > n)
                return 0;
            return Math.Floor(0.5 + Math.Exp(FactorialLn(n) - FactorialLn(k) - FactorialLn(n - k)));
        }
public static double BinomialCoefficient ( int n , int k ) { if ( k < 0 || k > n ) return 0 ; return Math . Floor ( 0.5 + Math . Exp ( FactorialLn ( n ) - FactorialLn ( k ) - FactorialLn ( n - k ) ) ) ; }
Returns a binomial coefficient of n and k as a double precision number
Returns a binomial coefficient of n and k as a double precision number
None
n
int
None
k
int
None