binomialLn function
Computes the natural logarithm of the binomial coefficient: ln(n
choose k
).
Implementation
double binomialLn(int n, int k) {
if (k < 0 || n < 0 || k > n) {
return double.negativeInfinity;
}
return factorialLn(n) - factorialLn(k) - factorialLn(n - k);
}