Java Binomial Coefficients binomialCoefficients(int n, int k)

Here you can find the source of binomialCoefficients(int n, int k)

Description

binomial Coefficients

License

Open Source License

Declaration

public static long binomialCoefficients(int n, int k) 

Method Source Code

//package com.java2s;

public class Main {
    public static long binomialCoefficients(int n, int k) {

        long Ank = 1;

        if (k < 0 || k > n) {
            return 0;
        }//from  w  w w  .j ava  2  s  .  com

        long i = n - k + 1;
        while (i <= n && Ank >= 0) {
            Ank = Ank * i;
            i = i + 1;
        }
        if (Ank < 0)
            return Integer.MAX_VALUE;
        return Ank;
    }
}

Related

  1. binomialCoefficient(int n, int k)
  2. binomialCoefficient(int n, int k)
  3. binomialCoefficient(long n, long k)
  4. binomialCoefficientDouble(final int n, final int k)
  5. binomialCoefficientLog(final int n, final int k)
  6. binomialPmf(int k, int n, double p)
  7. binomialRand(int n, double pp)