Skip to content

Commit b5b8570

Browse files
committed
doc: add doc and examples for lobbnum
1 parent 7588066 commit b5b8570

1 file changed

Lines changed: 39 additions & 4 deletions

File tree

src/numbers.jl

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,12 +97,47 @@ function catalannum(bn::Integer)
9797
end
9898

9999
"""
100-
lobbnum(m,n)
100+
lobbnum(m, n)
101101
102-
Compute the Lobb number `L(m,n)`, or the generalised Catalan number given by ``\\frac{2m+1}{m+n+1} \\binom{2n}{m+n}``.
103-
Wikipedia : https://en.wikipedia.org/wiki/Lobb_number
102+
Compute the Lobb number `L(m,n)`, or the generalised Catalan number given by:
103+
```math
104+
L_{m,n} = \\frac{2m+1}{m+n+1} \\binom{2n}{m+n}
105+
```
106+
For `m = 0`, we get the ``n``-th Catalan number.
107+
108+
See also: [`catalannum`](@ref).
109+
110+
# Examples
111+
```jldoctest
112+
julia> [ [lobbnum(m, n) for m in 0:n] for n in 0:5 ]
113+
6-element Vector{Vector{BigInt}}:
114+
[1]
115+
[1, 1]
116+
[2, 3, 1]
117+
[5, 9, 5, 1]
118+
[14, 28, 20, 7, 1]
119+
[42, 90, 75, 35, 9, 1]
120+
121+
julia> lobbnum(0, 25) == catalannum(25)
122+
true
123+
124+
julia> lobbnum(-1, 1)
125+
ERROR: DomainError with (m = -1, n = 1):
126+
m and n must be non-negative and m <= n
127+
Stacktrace:
128+
[...]
129+
130+
julia> lobbnum(5, 1)
131+
ERROR: DomainError with (m = 5, n = 1):
132+
m and n must be non-negative and m <= n
133+
Stacktrace:
134+
[...]
135+
```
136+
137+
# References
138+
- [Lobb number - Wikipedia](https://en.wikipedia.org/wiki/Lobb_number)
104139
"""
105-
function lobbnum(bm::Integer,bn::Integer)
140+
function lobbnum(bm::Integer, bn::Integer)
106141
if !(0 <= bm <= bn)
107142
throw(DomainError((m=bm, n=bn), "m and n must be non-negative and m <= n"))
108143
else

0 commit comments

Comments
 (0)