Program to compute the Fibonacci numbers, where F0 = 0, F1 = 1, and for all n >= 2, Fn is defined as Fn-1 + Fn-2.
The repo contains 3 algorithms to compute the Fibonacci numbers:
fib_recursive.cpp
: recursive implementation (non-memoized), runs in O(2n) timefib_iterative.cpp
: iterative solution, runs in O(n) time and O(1) spacefib_matrix.cpp
: matrix solution, runs in O(log n) time
The algorithms each contain mod
implementations where computations are done mod 65536 to prevent integer overflow.
Time calculations can be found in Fibonacci_Times.ipynb
.