Let's call T(n)T(n) the number of arithmetic operations we need to compute F(n)F(n). T(0)=T(1)=0T(0) = T(1) = 0, because those values are given to us. T(2)=1T(2) = 1, because we need to add F(0)F(0) and F(1)F(1). T(3)=2T(3) = 2, because we need to compute F(2)F(2) and then add it to F(1)F(1). In general, we have that T(n)=T(n1)+T(n2)+1T(n) = T(n-1) + T(n-2) + 1: we need to compute the two numbers below the one we want and then add them together. The T(n)T(n) sequence bears a striking resemblance to the Fibonacci sequence if you compare the definitions—this is a good example of how the Fibonacci sequence or similar sequences pop up in analyzing recursive algorithms.1

I've graphed T(n)T(n) for nn from 0 to 50. Note the scale on the y-axis, from 0 to 20 billion! TnT_n grows exponentially, and gets really big really fast. Clearly this won't be a viable way of computing large Fibonacci numbers.


  1. A famous example is the Euclidean algorithm for computing the greatest common denominator, which has its worst performace for consecutive Fibonacci numbers.
plot

Let's call T(n)T(n) the number of arithmetic operations we need to compute F(n)F(n). T(0)=T(1)=0T(0) = T(1) = 0, because those values are given to us. T(2)=1T(2) = 1, because we need to add F(0)F(0) and F(1)F(1). T(3)=2T(3) = 2, because we need to compute F(2)F(2) and then add it to F(1)F(1). In general, we have that T(n)=T(n1)+T(n2)+1T(n) = T(n-1) + T(n-2) + 1: we need to compute the two numbers below the one we want and then add them together. The T(n)T(n) sequence bears a striking resemblance to the Fibonacci sequence if you compare the definitions—this is a good example of how the Fibonacci sequence or similar sequences pop up in analyzing recursive algorithms.1

I've graphed T(n)T(n) for nn from 0 to 50. Note the scale on the y-axis, from 0 to 20 billion! TnT_n grows exponentially, and gets really big really fast. Clearly this won't be a viable way of computing large Fibonacci numbers.


  1. A famous example is the Euclidean algorithm for computing the greatest common denominator, which has its worst performace for consecutive Fibonacci numbers.
plot