title: Pascal Triangle Recursive Program optimization in C++
body: <p>I have built recursive function to compute Pascal's triangle values. </p>
  
  <p>Is there a way to optimize it? </p>
  
  <p>Short reminder about Pascal's triangle: C(n, k) = C(n-1, k-1) + C(n-1, k)
  My code is: </p>
  
  <pre><code>int Pascal(int n, int k) {
  if (k == 0) return 1;
  if (n == 0) return 0;
  return Pascal(n - 1, k - 1) + Pascal(n - 1, k);
  }
  </code></pre>
  
  <p>The inefficiency I see is that it stores some values twice. 
  Example: 
  C(6,2) = C(5,1) + C(5,2)
  C(6,2) = C(4,0) + C(4,1) + C(4,1) + C(4,2) 
  it will call C(4,1) twice</p>
  
  <p>Any idea how to optimize this function? </p>
  
  <p>Thanks</p>