Adds optimization of fib that only calculates results for an input once.