2. Fibonacci Revised

If asked in a technical interview, how would you improve the runtime performance of this code? Why would your version be more effective?

func fib(_ n: Int) -> Int {
    guard n > 1 else { return n }
    return fib(n-1) + fib(n-2)
}

Hints

When learning the basics of recursive algorithms, the Fibonacci sequence is a widely used standard for understanding this process. However, there are a number of ways we can write this algorithm. Even though our function is technically correct, how could this function be improved? What is being implied when we say the algorithm is inefficient?