mirror of
https://gitee.com/dromara/hutool.git
synced 2025-04-05 17:37:59 +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 cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
|
||||
/**
|
||||
* 组合,即C(n, m)<br>
|
||||
@ -53,11 +54,10 @@ public class Combination implements Serializable {
|
||||
* @return 组合数
|
||||
*/
|
||||
public static long countAll(int n) {
|
||||
long total = 0;
|
||||
for (int i = 1; i <= n; i++) {
|
||||
total += count(n, i);
|
||||
if (n < 0 || n > 63) {
|
||||
throw new IllegalArgumentException(StrUtil.format("countAll must have n >= 0 and n <= 63, but got n={}", n));
|
||||
}
|
||||
return total;
|
||||
return n == 63 ? Long.MAX_VALUE : (1L << n) - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user