Class BinomialCoefficient

java.lang.Object
org.apache.commons.numbers.combinatorics.BinomialCoefficient

public class BinomialCoefficient
extends java.lang.Object
Representation of the binomial coefficient. It is "n choose k", the number of k-element subsets that can be selected from an n-element set.
  • Constructor Summary

    Constructors 
    Constructor Description
    BinomialCoefficient()  
  • Method Summary

    Modifier and Type Method Description
    static long value​(int n, int k)
    Computes de binomial coefficient.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • value

      public static long value​(int n, int k)
      Computes de binomial coefficient. The largest value of n for which all coefficients can fit into a long is 66.
      Parameters:
      n - Size of the set.
      k - Size of the subsets to be counted.
      Returns:
      n choose k.
      Throws:
      java.lang.IllegalArgumentException - if n < 0.
      java.lang.IllegalArgumentException - if k > n.
      java.lang.ArithmeticException - if the result is too large to be represented by a long.