Here you can find the source of binomialCoeff(int n, int k)
public static long binomialCoeff(int n, int k)
//package com.java2s; // BSD License (http://lemurproject.org/galago-license) public class Main { /** Multiplicative form from Wikipedia * @author irmarc/* w w w.j a va2 s.c o m*/ */ public static long binomialCoeff(int n, int k) { if (n <= k) { return 1; } int c; if (k > n - k) { // take advantage of symmetry k = n - k; } c = 1; for (int i = 0; i < k; i++) { c *= (n - i); c /= (i + 1); } return c; } }