title: Converting recursive formulate into pseudocode using memoization
body: <p>i've been trying to turn the recurrence formula underneath into a pseudocode that uses memoization, however currently all i know is my below attempt is incorrect, is anyone able to point me in the right direction?</p>
  
  <p>My recurrence formula:</p>
  
  <pre><code>N(C,i) =
  1 if C = 0
  0 if i=0 or C&lt;0}
  N(C-p_i, i-1) + N(C, i-1) otherwise
  </code></pre>
  
  <p>My current attempt:</p>
  
  <pre><code>MEM-N(C, i, r)
      if r[i] &gt;= 0 then
          return r[i]
      if i = 0 and r[i] &gt;= 0 or C &lt; 0 and r[i] &gt;= 0 then
          return 0
      else if C = 0 and r[i] &gt;= 0 then
          return 1
      else
          q = -$\infty$
          q = MEM-N(C - $p_i$, i-1) + MEM-N(C,i - x, r)
          r[i] = q
          return q
  </code></pre>