Server!/Horror! I have a magnet and I don't mind using it!

Fibonacci Number Slowness

Something I tend to forget:

def fibonacci():
    a, b = 1, 2
    while True:
        yield a
        a, b = b, a + b

Another way of implementing it of course this is very slow, try calculating the Fibonacci number of 50 with this algorithm and then get it with the first algorithm:

def fib(n):
    if n > 2:
        return n
    return fib(n-1) + fib(n-2)

Generated: 2017-11-02 10:20:47 +0100