File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -163,6 +163,43 @@ function narayana(bn::Integer,bk::Integer)
163163 div (binomial (n, k)* binomial (n, k - 1 ) , n)
164164end
165165
166+ """
167+ fibonaccinum(n)
168+
169+ Compute the ``n``th Fibonacci number, ``F_n``, given by:
170+ ```math
171+ F_0 = 0
172+ \\\\
173+ F_1 = 1
174+ \\\\
175+ F_n = F_{n-1} + F_{n-2}
176+ ```
177+
178+ # Examples
179+ ```jldoctest
180+ julia> [ fibonaccinum(i) for i in 0:5 ]
181+ 6-element Vector{BigInt}:
182+ 0
183+ 1
184+ 1
185+ 2
186+ 3
187+ 5
188+
189+ julia> fibonaccinum(13)
190+ 233
191+
192+ julia> fibonaccinum(-1)
193+ ERROR: DomainError with -1:
194+ n must be nonnegative
195+ Stacktrace:
196+ [...]
197+ ```
198+
199+ # References
200+ - [Fibonacci sequence - Wikipedia](https://en.wikipedia.org/wiki/Fibonacci_sequence)
201+ - [DLMF: §26.11 Fibonacci number](https://dlmf.nist.gov/26.11#p4)
202+ """
166203function fibonaccinum (n:: Integer )
167204 if n < 0
168205 throw (DomainError (n, " n must be nonnegative" ))
You can’t perform that action at this time.
0 commit comments