title: Algorithm for Calculating Binomial Coefficient
body: <p>I need a way of calculating combinations without running out of memory. Here's what i have so far.</p>
  
  <pre><code>public static long combination(long n, long k) // nCk
  {
      return (divideFactorials(factorial(n), ((factorial(k) * factorial((n - k))))));
  }
  
  public static long factorial(long n)
  {
      long result;
      if (n &lt;= 1) return 1;
      result = factorial(n - 1) * n;
      return result;
  }
  
  public static long divideFactorials(long numerator, long denominator)
  {
      return factorial(Math.Abs((numerator - denominator)));
  }
  </code></pre>
  
  <p>I have tagged it as C#, but the solution should ideally be language independent.</p>