title: Factorials in Swift
body: <p>I need a good factorial function. The one I have written here works entirely, except when n gets far too large. This is for a calculator app, and I can return 0 / 0 for values that cannot be factorialed because I have an error checker that will declare that as impossible. However performing the function on a very large number crashes the app. I can't use a range operator because my types are doubles. </p>
  
  <pre><code>func factorial(n: Double) -&gt; Double {
      if n &gt;= 0 {
          return n == 0 ? 1 : n * self.factorial(n - 1)
      } else {
          return 0 / 0
      }
  }
  </code></pre>
  
  <p>What is the best way to do this?</p>