text: public static double nChooseK(int n, int k) {double d = 1;if (n<0 || k<0 || n<k) {d= Double.NaN;}else {int minnk = Math.min(n-k, k);int maxnk = Math.max(n-k, k);for (int i=maxnk; i<n; i++) {d *= i+1;}d /= factorial(minnk);}return d;}