title: Recursive method for Pascal's triangle
body: <p>I have written a method to evaluate a <em>Pascal's triangle</em> of <code>n</code> rows. However when I test the method I receive the error:</p>
  <pre><code>Exception in thread &quot;main&quot; java.lang.ArrayIndexOutOfBoundsException: -1
  </code></pre>
  <p>Here is the code:</p>
  <pre class="lang-java prettyprint-override"><code>public static int[] PascalTriangle(int n) {
      int[] pt = new int[n + 1];
      if (n == 0) {
          pt[0] = 1;
          return pt;
      }
      int[] ppt = PascalTriangle(n - 1);
      pt[0] = pt[n] = 1;
      for (int i = 0; i &lt; ppt.length; i++) {
          pt[i] = ppt[i - 1] + ppt[i];
      }
      return pt;
  }
  </code></pre>
  <p>Please let me know if you have any ideas for how the code could be edited to fix the problem.</p>