File tree Expand file tree Collapse file tree 1 file changed +31
-3
lines changed
Expand file tree Collapse file tree 1 file changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -150,12 +150,40 @@ end
150150"""
151151 narayana(n,k)
152152
153- Compute the Narayana number `N(n,k)` given by ``\\ frac{1}{n}\\ binom{n}{k}\\ binom{n}{k-1}``
154- Wikipedia : https://en.wikipedia.org/wiki/Narayana_number
153+ Compute the Narayana number `N(n,k)` given by ``\\ frac{1}{n}\\ binom{n}{k}\\ binom{n}{k-1}``,
154+ where ``1 \\ leq k \\ leq n``.
155+
156+ # Examples
157+ ```jldoctest
158+ julia> narayana(1, 1)
159+ 1
160+
161+ julia> narayana(8, 5)
162+ 490
163+
164+ julia> [ [narayana(n, k) for k in 1:n] for n in 1:6 ]
165+ 6-element Vector{Vector{BigInt}}:
166+ [1]
167+ [1, 1]
168+ [1, 3, 1]
169+ [1, 6, 6, 1]
170+ [1, 10, 20, 10, 1]
171+ [1, 15, 50, 50, 15, 1]
172+
173+ julia> narayana(3, 4)
174+ ERROR: DomainError with (n = 3, k = 4):
175+ n and k must be 1 <= k <= n
176+ Stacktrace:
177+ [...]
178+ ```
179+
180+ # References
181+ - [Narayana number - Wikipedia](https://en.wikipedia.org/wiki/Narayana_number)
182+ - [DLMF: §26.6 Narayana Number](https://dlmf.nist.gov/26.6#Px3)
155183"""
156184function narayana (bn:: Integer ,bk:: Integer )
157185 if ! (1 <= bk <= bn)
158- throw (DomainError (" Domain is 1 <= k <= n" ))
186+ throw (DomainError ((n = bn, k = bk), " n and k must be 1 <= k <= n" ))
159187 else
160188 n = BigInt (bn)
161189 k = BigInt (bk)
You can’t perform that action at this time.
0 commit comments