From ad5bba270365d1422bfb9f348ef917ced3eb8796 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=94=9F=E5=B9=B3?= Date: Thu, 26 Aug 2021 21:05:07 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BD=93n=20=3D=20m=E6=97=B6=EF=BC=8CC(n,=20m)?= =?UTF-8?q?=20=3D=20C(n,=20n)=20=3D=201=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/cn/hutool/core/math/Combination.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/hutool-core/src/main/java/cn/hutool/core/math/Combination.java b/hutool-core/src/main/java/cn/hutool/core/math/Combination.java index ccc5bea2b..7da8d3b42 100644 --- a/hutool-core/src/main/java/cn/hutool/core/math/Combination.java +++ b/hutool-core/src/main/java/cn/hutool/core/math/Combination.java @@ -38,12 +38,9 @@ public class Combination implements Serializable { * @return 组合数 */ public static long count(int n, int m) { - if (0 == m) { + if (0 == m || n == m) { return 1; } - if (n == m) { - return NumberUtil.factorial(n) / NumberUtil.factorial(m); - } return (n > m) ? NumberUtil.factorial(n, n - m) / NumberUtil.factorial(m) : 0; }