First, you must determine the basic operation of the algorithm. Place a counter to calculate how many times the main operation works until your algorithm completes. Try to designate this counter as n. In Fibonacci series, the main operation is addition (adding the last two elements gives you the following) To calculate the nth number, you need to add n-1. Thus, the complexity of the Fibonacci series is realized as O (n)
source
share