Recursive calculates the n-th fibonacci number recursively by adding the previous two Fibonacci numbers. This algorithm is extremely slow for bigger numbers, but provides a simpler implementation.
(n uint)
| 51 | // Recursive calculates the n-th fibonacci number recursively by adding the previous two Fibonacci numbers. |
| 52 | // This algorithm is extremely slow for bigger numbers, but provides a simpler implementation. |
| 53 | func Recursive(n uint) uint { |
| 54 | if n <= 1 { |
| 55 | return n |
| 56 | } |
| 57 | |
| 58 | return Recursive(n-1) + Recursive(n-2) |
| 59 | } |
no outgoing calls