code: public static int nChooseK(int n, int k) {
      k = Math.min(k, n - k);
      if (k == 0) {
        return 1;
      }
      int accum = n;
      for (int i = 1; i < k; i++) {
        accum *= (n - i);
        accum /= i;
      }
      return accum / k;
    }
docs: Computes n choose k in an efficient way.  Works with
  k == 0 or k == n but undefined if k < 0 or k > n
  
  @return fact(n) / fact(k) * fact(n-k)