The Fibonacci numbers are the numbers in the following integer sequence 0, 1, 1, 2, 3, 5, 8, 13…

Mathematically Fibonacci numbers can be written by the following recursive formula.

For seed values F(0) = 0 and F(1) = 1 F(n) = F(n-1) + F(n-2)

Before proceeding with this article make sure you are familiar with the recursive approach discussed in Program for Fibonacci numbers

**Analysis of the recursive Fibonacci program:**

We know that the recursive equation for Fibonacci is =++.

What this means is, the time taken to calculate fib(n) is equal to the sum of time taken to calculate fib(n-1) and fib(n-2). This also includes the constant time to perform the previous addition.

On solving the above recursive equation we get the upper bound of Fibonacci as but this is not the tight upper bound. The fact that Fibonacci can be mathematically represented as a linear recursive function can be used to find the tight upper bound.

Now Fibonacci is defined as

= +

The characteristic equation for this function will be

= +

– – =

Solving this by quadratic formula we can get the roots as

= (+)/ and =( – )/

Now we know that solution of a linear recursive function is given as

= +

where and are the roots of the characteristic equation.

So for our Fibonacci function = + the solution will be

= +

Clearly and are asymptotically the same as both functions are representing the same thing.

Hence it can be said that

=

or we can write below (using the property of Big O notation that we can drop lower order terms)

=

=

This is the tight upper bound of fibonacci.\

**Fun Fact:**

1.6180 is also called the golden ratio. You can read more about golden ratio here: Golden Ratio in Maths

This article is contributed by **Vineet Joshi**. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready.

## Recommended Posts:

- C program for Time Complexity plot of Bubble, Insertion and Selection Sort using Gnuplot
- Time Complexity of building a heap
- An interesting time complexity question
- Time Complexity where loop variable is incremented by 1, 2, 3, 4 ..
- Time Complexity of a Loop when Loop variable “Expands or Shrinks” exponentially
- Practice Questions on Time Complexity Analysis
- Time Complexity Analysis | Tower Of Hanoi (Recursion)
- Python Code for time Complexity plot of Heap Sort
- Time Complexity of Loop with Powers
- A Time Complexity Question
- Understanding Time Complexity with Simple Examples
- Check if a M-th fibonacci number divides N-th fibonacci number
- Check if sum of Fibonacci elements in an Array is a Fibonacci number or not
- Count Fibonacci numbers in given range in O(Log n) time and O(1) space
- Find Index of given fibonacci number in constant time
- What does 'Space Complexity' mean?
- Complexity of different operations in Binary tree, Binary Search Tree and AVL tree
- Knowing the complexity in competitive programming
- Cyclomatic Complexity
- Complexity Analysis of Binary Search