Notice that it takes a lot longer to create the list of 30 because every time it calls the
procedure Fib, Maple âforgetsâ that it probably has calculated one of those numbers before.
For example, say we want to find Fib(5). Then Fib calls itself to find Fib(3) and Fib(4),
but Fib(4) calls itself to find Fib(3) and Fib(2). So our procedure just called itself
twice to find Fib(3), and even more times to find Fib(2)!
We can help Maple along by using a command that lets it ârememberâ that it already
figured out Fib(3) and so it doesnât need to recursively compute it again. Add a line
directly after your first line of the procedure Fib that says:
Then create your list of the first 30 Fibonacci numbers again. What a difference it makes!
Note: The main chunk of code here is just your code from part (a) with one line added.
Then create the list of 30 Fibonacci numbers in (c).
Then see how long it took, as you did in (d).