title: Memoization fibonacci algorithm in python
body: <p>I have this memoization technique to reduce the number of calls getting a Fibonacci sequence number: </p>
  
  <pre><code>def fastFib(n, memo):
      global numCalls
      numCalls += 1
      print 'fib1 called with', n
      if not n in memo:
          memo[n] = fastFib(n-1, memo) + fastFib(n-2, memo)
          return memo[n]
  
  
  def fib1(n):
      memo = {0:1, 1:1}
      return fastFib(n, memo)
  
  
  numCalls = 0
  n = 6
  res = fib1(n)
  print 'fib of', n,'=', res, 'numCalls = ', numCalls
  </code></pre>
  
  <p>But i am stuck at here: <code>memo[n] = fastFib(n-1, memo) + fastFib(n-2, memo)</code> and here <code>memo = {0:1, 1:1}</code>. How is it exactly reducing the number of calls each time i want to get fib of a number?</p>