Dynamic programming approach to calculating the nth fibonacci number (with memoization).