Skip to main content
1 of 3
Zefick
  • 341
  • 2
  • 6

The simplest Fibonacci function without memoization and recursion:

def fibonacci(n) :
    a,b = 1,1
    while n > 2 :
        a,b,n = b, b+a, n-1
    return b
Zefick
  • 341
  • 2
  • 6