Skip to content

Commit bc12ba1

Browse files
committed
Update doc for multinomial
1 parent b28457c commit bc12ba1

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

src/factorials.jl

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,34 @@ end
9595
"""
9696
multinomial(k...)
9797
98-
Multinomial coefficient where `n = sum(k)`.
98+
Compute the multinomial coefficient
99+
``\\binom{n}{k_1,k_2,...,k_i} = \\frac{n!}{k_1!k_2! \\cdots k_i!}, n = \\sum{k_i}``.
100+
Throws an `OverflowError` when the input is too large.
101+
102+
See Also: `binomial`.
103+
104+
# Examples
105+
```jldoctest
106+
julia> # (x+y)^2 = x^2 + 2xy + y^2
107+
108+
julia> multinomial(2, 0)
109+
1
110+
111+
julia> multinomial(1, 1)
112+
2
113+
114+
julia> multinomial(0, 2)
115+
1
116+
117+
julia> multinomial(10, 10, 10, 10)
118+
ERROR: OverflowError: 5550996791340 * 847660528 overflowed for type Int64
119+
Stacktrace:
120+
[...]
121+
```
122+
123+
# External links
124+
- [Definitions](https://dlmf.nist.gov/26.4.2) on DLMF
125+
- [Multinomial theorem](https://en.wikipedia.org/wiki/Multinomial_theorem) on Wikipedia
99126
"""
100127
function multinomial(k...)
101128
s = 0

0 commit comments

Comments
 (0)