title: How to calculate matrix determinant? n*n or just 5*5
body: <p>everyone. I need to find matrix <code>n*n</code> (or <code>5*5</code>) determinant. I have a function translated from Pascal, but there's <code>INDEX OUT OF RANGE EXCEPTION</code>. Could somebody help me?  </p>
  
  <p>Here's my code:</p>
  
  <pre><code>public static double DET(double[,] a, int n)
      {
          int i, j, k;
          double det = 0;
          for (i = 0; i &lt; n - 1; i++)
          {   
              for (j = i + 1; j &lt; n + 1; j++)
              {
                  det = a[j, i] / a[i, i];
                  for (k = i; k &lt; n; k++)
                      a[j, k] = a[j, k] - det * a[i, k]; // Here's exception
              }
          }
          det = 1;
          for (i = 0; i &lt; n; i++)
              det = det * a[i, i];
              return det;
      }
  </code></pre>
  
  <p>Thanx for any help.</p>