November 2017
Intermediate to advanced
670 pages
17h 35m
English
The Fibonacci sequence is a sequence of numbers where each number is equal to the previous two numbers added together. Here's an example of this:
1 1 2 3 5 8 13 21 34
So, 1 plus 1 is 2, 2 plus 3 is 5, 5 plus 8 is 13, and so on.
Let's use the Fibonacci sequence to help illustrate a number of concepts.
A recursive function is a function that calls itself in order to break down complex input into simpler ones. With each recursive call, the input problem must be simplified in such a way that eventually the base case must be reached.
The Fibonacci sequence can be easily implemented as a recursive function:
func Fibonacci(x int) int { if x == 0 { return 0 } else if x <= ...