human
I am working on the file "Interview Cake.ipynb".
The first task is:
Fibonacci
Can you write Python code for it?

What is a the Python code you requested?
assistant
#Here is the Python code you requested.

class Fibber:
    def __init__(self):
        self.memo = {}
    
    def fib(self, n):
        if n < 0:
            raise Exception('Index was negative. No such thing as a negative index in a series')
        
        elif n < 2:
            return n;
        
        if n in self.memo:
            return self.memo[n]
        
        result = self.fib(n-1) + self.fib(n-2)
        
        self.memo[n] = result
        
        return result

def fib(n):
    
    if n < 0:
        raise Exception("Index was negative. Cannot have a negaitve index in a series")
        
    if n < 2:
        return n
    
    prev_prev = 0
    prev = 1
    for _ in xrange(n-1):
        current = prev + prev_prev
        prev_ prev = prev
        prev = current
    
    return current