nCk function

double nCk(
  1. num n,
  2. num k
)

binomial coefficients

src: http://blog.plover.com/math/choose.html

Implementation

double nCk(num n, num k) {
  double count = n.toDouble();
  if (k > count) return 0;
  if (k == 0) return 1;
  double coEff = 1;
  for (int i = 1; i <= k; i++) {
    coEff *= count;
    coEff /= i;
    count--;
  }
  return coEff;
}