public final class CombinatoricsUtils extends Object
| Modifier and Type | Method | Description |
|---|---|---|
static long |
stirlingS2(int n,
int k) |
Returns the
Stirling number of the second kind, "
S(n,k)", the number of
ways of partitioning an n-element set into k non-empty
subsets. |
public static long stirlingS2(int n,
int k)
throws NotPositiveException,
NumberIsTooLargeException,
MathArithmeticException
S(n,k)", the number of
ways of partitioning an n-element set into k non-empty
subsets.
The preconditions are 0 <= k <= n (otherwise
NotPositiveException is thrown)
n - the size of the setk - the number of non-empty subsetsS(n,k)NotPositiveException - if k < 0.NumberIsTooLargeException - if k > n.MathArithmeticException - if some overflow happens, typically for n exceeding 25 and
k between 20 and n-2 (S(n,n-1) is handled specifically and does not overflow)Copyright © 2003–2017 The Apache Software Foundation. All rights reserved.