title: Memoizing fibonacci sequence in python
body: <p>I have to write a <code>fib_memoize(n)</code> function that should be recursive but it should memoize its answer so that it's running time is <code>O(n)</code>.<br>
  This is what I have: </p>
  
  <pre><code>def fib_memoize(n):
      memo = {}
      if n in memo:
          return memo[n]
      else:
          if n &lt;=2:
              f = 1
          else:
              f = fib_recursive(n-1) + fib_recursive(n-2)
  
          memo[n] = f
          return f
  </code></pre>
  
  <p>This is giving me an assertion error saying <code>1 != 0</code>. What is this pointing to? What am I missing?</p>
  
  <p>This is my <code>fib_recursive</code> function (passes the tests):</p>
  
  <pre><code>def fib_recursive(n):
      if n &lt;=1:
          return n
      else:
          return fib_recursive(n-1) + fib_recursive(n-2)
  </code></pre>