- #1
rem1618
- 14
- 0
def fib(n):
f0, f1, = 0, 1
for i in range(n - 1):
f0, f1 = f1, f0 + f1
return f1
It looks like it'd be linear, given there's only one loop, but when I plotted n against runtime, the relationship was quadratic, why?
f0, f1, = 0, 1
for i in range(n - 1):
f0, f1 = f1, f0 + f1
return f1
It looks like it'd be linear, given there's only one loop, but when I plotted n against runtime, the relationship was quadratic, why?