public class BinomialCoefficientUtil
extends java.lang.Object
| Constructor and Description |
|---|
BinomialCoefficientUtil() |
| Modifier and Type | Method and Description |
|---|---|
static long |
binomialCoefficient(int n,
int k)
Binomial Coefficient, "
n choose k", the number of
k-element subsets that can be selected from an
n-element set. |
public static long binomialCoefficient(int n,
int k)
throws java.lang.ArithmeticException
n choose k", the number of
k-element subsets that can be selected from an
n-element set.
Preconditions:
0 <= k <= n (otherwise
IllegalArgumentException is thrown)long. The
largest value of n for which all coefficients are
< Long.MAX_VALUE is 66. If the computed value exceeds
Long.MAX_VALUE an ArithmeticException is
thrown.n - the size of the setk - the size of the subsets to be countedn choose kjava.lang.ArithmeticException - if n < 0 or k > n or
the result is too large to be represented by a long integer.