MathUtils { public static long binomialCoeff(int n, int k) { if (n <= k) { return 1; } int c; if (k > n - k) { k = n - k; } c = 1; for (int i = 0; i < k; i++) { c *= (n - i); c /= (i + 1); } return c; } private  MathUtils(); static long binomialCoeff(int n, int k); static double logSumExp(double[] scores); static double logWeightedGeometricMean(double[] weights, double[] logScores); static double weightedArithmeticMean(double[] weights, double[] scores); static double weightedGeometricMean(double[] weights, double[] scores); static double weightedLogSumExp(double[] weights, double[] scores); static double logprob(double input); static double clamp(double input, double min, double max); static double sigmoid(double t);  }
@Test public void testBinomialCoeff() throws Exception { long result = MathUtils.binomialCoeff(7, 3); assertEquals(35, result); result = MathUtils.binomialCoeff(5, 3); assertEquals(result, 10); }