mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
Update Combination.java
This commit is contained in:
parent
2a24b7fd6e
commit
edf01b772d
@ -6,6 +6,7 @@ import java.util.Arrays;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import cn.hutool.core.util.NumberUtil;
|
import cn.hutool.core.util.NumberUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 组合,即C(n, m)<br>
|
* 组合,即C(n, m)<br>
|
||||||
@ -53,11 +54,10 @@ public class Combination implements Serializable {
|
|||||||
* @return 组合数
|
* @return 组合数
|
||||||
*/
|
*/
|
||||||
public static long countAll(int n) {
|
public static long countAll(int n) {
|
||||||
long total = 0;
|
if (n < 0 || n > 63) {
|
||||||
for (int i = 1; i <= n; i++) {
|
throw new IllegalArgumentException(StrUtil.format("countAll must have n >= 0 and n <= 63, but got n={}", n));
|
||||||
total += count(n, i);
|
|
||||||
}
|
}
|
||||||
return total;
|
return n == 63 ? Long.MAX_VALUE : (1L << n) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user