I have been learning about the fibonacci sequence. I've been learning about two different implementations of fibonacci, a short program, and a longer, but faster algorithm.

Short, elegant version:

def fib(n): (excuse my pseudocode )

if n=0 return 0 #since fib(0)=0

if n=1 return 1 #since fib(1)=1

return fib(n-1) + fib(n-2)

The above implementation is fast for up to n=30, however, for n=100 it will crash for a long while before printing the answer.

I understand the above code.

#More complex implementation

def fib(n):

previousFib=0 currentFib=1

if n=0

return 0

elif n=1

return 1

**repeat (n-1) times**#I don't understand why repeat for n-1 times

newFib=previousFib+currentFib

previousFib=currentFib

currentFib=newFib

return currentFib

**I would hugely appreciate, if someone could explain the above implementation. I don't understand it from**

the bold line to the end.

the bold line to the end.

Thanks in advance