Here you can find the source of binomialCoefficient(int n, int k)
public static long binomialCoefficient(int n, int k)
//package com.java2s; /******************************************************************************* * Copyright (c) 2010 University of Illinois at Urbana-Champaign and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:// w w w . j a v a 2 s . c o m * UIUC - Initial API and implementation *******************************************************************************/ public class Main { /** @return the binomial coefficient <i>C(n, k)</i> */ public static long binomialCoefficient(int n, int k) { if (k > n) return 0; long result = 1; for (int i = 1; i <= k; i++) result = result * (n - k + i) / i; return result; } }