Skip to main content
added 12 characters in body
Source Link
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

But with memoization multiple calls for different inputs will be faster. You can modify this function to find solution in one call:

def fibonacci(digits) :
    a,b,n = 1,1,2
    while len(str(b)) < digits :
        a, b, n = b, b+a, n+1
    return n

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

But with memoization multiple calls for different inputs will be faster. You can modify this function to find solution:

def fibonacci(digits) :
    a,b,n = 1,1,2
    while len(str(b)) < digits :
        a, b, n = b, b+a, n+1
    return n

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

But with memoization multiple calls for different inputs will be faster. You can modify this function to find solution in one call:

def fibonacci(digits) :
    a,b,n = 1,1,2
    while len(str(b)) < digits :
        a, b, n = b, b+a, n+1
    return n
added 273 characters in body
Source Link
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

But with memoization multiple calls for different inputs will be faster. You can modify this function to find solution:

def fibonacci(digits) :
    a,b,n = 1,1,2
    while len(str(b)) < digits :
        a, b, n = b, b+a, n+1
    return n

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

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

But with memoization multiple calls for different inputs will be faster. You can modify this function to find solution:

def fibonacci(digits) :
    a,b,n = 1,1,2
    while len(str(b)) < digits :
        a, b, n = b, b+a, n+1
    return n
Source Link
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