Bug fix for math::BinomialCoefficient(n, k); the previous implementation returned 1 for negative k values, which is not correct (should be zero.
This commit is contained in:
@@ -15,8 +15,9 @@ double math::BinomialCoefficient(int n, int k) {
|
||||
double nchsk = 1;
|
||||
int i;
|
||||
|
||||
if(k > n)
|
||||
if(k > n || k < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(k < n_k) {
|
||||
k = n_k;
|
||||
|
||||
Reference in New Issue
Block a user