Class BinomialCoefficient
- java.lang.Object
-
- org.apache.commons.numbers.combinatorics.BinomialCoefficient
-
public final class BinomialCoefficient extends Object
Representation of the binomial coefficient. It is "n choose k
", the number ofk
-element subsets that can be selected from ann
-element set.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static long
value(int n, int k)
Computes the binomial coefficient.
-
-
-
Method Detail
-
value
public static long value(int n, int k)
Computes the binomial coefficient. The largest value ofn
for which all coefficients can fit into along
is 66.- Parameters:
n
- Size of the set.k
- Size of the subsets to be counted.- Returns:
n choose k
.- Throws:
IllegalArgumentException
- ifn < 0
.IllegalArgumentException
- ifk > n
.ArithmeticException
- if the result is too large to be represented by along
.
-
-