可重复组合数计算器

Combination with Repetition Calculator

Compute combinations with repetition C(n+r-1, r) from type and pick counts.

📐 计算公式
可重复组合:C(n+r−1, r) = (n+r−1)! ÷ (r!·(n−1)!);对照不重复组合 C(n,r) = n! ÷ (r!(n−r)!),n <r 时记 0。校验:n、r 四舍五入取整、封顶 1000,<1 提示报错。判据:主式按对数空间 lnC=ln(n+r−1)!−ln r!−ln(n−1)! 后 exp 复原,超大结果自动转科学计数(如 1.234e+59),不再溢出;对比 C(n,r) 用连乘法。

输入类型数 n 与选取数 r,求可重复组合数。

Formula & Standard References

Item Formula / Note Source / Standard
Combinations with repetition Choosing r items from n types with repetition gives C(n + r - 1, r) Feller W., An Introduction to Probability Theory and Its Applications, Vol. 1, Wiley
Stars and bars Equivalent to placing r identical balls into n boxes, giving C(n + r - 1, r) Feller W., An Introduction to Probability Theory and Its Applications, Vol. 1
Versus combinations without repetition Without repetition the count is C(n, r), and C(n, r) <= C(n + r - 1, r) Brualdi RA, Introductory Combinatorics (5th ed.)
Typical use Used for recipes, allocations and multiset counting where items may repeat Feller W., An Introduction to Probability Theory and Its Applications, Vol. 1
📌 计算说明
  • 星棒法经典计数。
  • n=5,r=3 → 35。

📚 深度解析:可重复组合

💡 常见使用场景

口味可重复
3 种口味选 2 杯(可同味),可重复组合数 = C(n+k-1,k)=C(3+2-1,2)=C(4,2)=6 种:AA/AB/AC/BB/BC/CC。
与不可重复对比
若不可重复(每味限一杯)则 C(3,2)=3 种;允许重复后增到 6 种,因为出现了 AA/BB/CC 这类同味组合。

❓ 常见问题(FAQ)

可重复组合公式是什么?
C(n+k-1, k),其中 n 为种类数、k 为选取个数。等价于是 n 个类别、k 个 indistinguishable 选取的「星棒法」。
什么时候用可重复组合?
当「选了还能再选」时用,如自助取多份、口味可重复、有放回地抽类别。无放回且每类唯一则用普通组合 C(n,k)。