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:
Dongryeol Lee
2008-08-14 17:55:22 +00:00
parent 07a93adfeb
commit fc94b49ada
+2 -1
View File
@@ -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;