Ad

Сan not be stored list in the memory

Code
Diff
  • def fib(x):
        f1, f2 = 0, 1
        for x in range(x):
            f1, f2 = f2, (f1 + f2)
        return f2
    • def fib(x):
    • fib = [1,1]
    • for x in range(x-1):
    • fib.append(fib[-2]+fib[-1])
    • return fib[-1]
    • f1, f2 = 0, 1
    • for x in range(x):
    • f1, f2 = f2, (f1 + f2)
    • return f2