Pure Programmer
Blue Matrix


Cluster Map

Project: Fibonacci Numbers with Memoization

In the previoius project we could see that computing Fibonacci Numbers with larger values of n can take a long time using recursion. Using a technique called memoization we can cache previously computed values so that we don't have to keep computing them over and over. Create an array to hold the previously computed results. Then when the function is called, look in the list first to see if the answer is there. If not, compute the Fibonacci number and put the result into the list before returning the result.

What is the largest Fibonacci Number that can be computed accurately before overflow occurs? Add a precondition to your function to prevent operation using a value that would produce an incorrect result.

See [[wikipidea or link]]
See Fibonacci1

Output
$ swiftc Fibonacci2.swift -I . -L . -lUtils error: link command failed with exit code 1 (use -v to see invocation) ld: library not found for -lUtils clang: error: linker command failed with exit code 1 (use -v to see invocation)

Solution