title: Integer Partition (algorithm and recursion)
body: <p>Finding how many combinations of a sum number (the variable <strong>n</strong> in code). For ex.:</p>
  <blockquote>
  <p>3 = 1+1+1 = 2+1 = 3 =&gt; ANS is 3</p>
  <p>5 = 5 = 4+1 = 3+2 = 3+1+1 = 2+2+1 = 2+1+1+1 = 1+1+1+1+1 =&gt; ANS is 7</p>
  </blockquote>
  <p>In the following example, <strong>m</strong> is the max number and <code>n</code> is sum,
  the aim is to find how many (sum) combination does it have.</p>
  <p>I just want to know why do <code>p(n, m) = p(n, m - 1) + p(n - m, m)</code> ?</p>
  <p>The code here:</p>
  <pre><code>int p (int n, int m)
  {
      if (n == m)
          return 1 + p(n, m - 1);
      if (m == 0 || n &lt; 0)
          return 0;
      if (n == 0 || m == 1)
          return 1;
  
      return p(n, m - 1) + p(n - m, m);
  
  }
  </code></pre>
  <p>Appreciated!</p>