title: In Swift 3, how to calculate the factorial when the result becomes too high?
body: <p>I have written this function to return the factorial of a given number</p>
  
  <pre><code>func factorial(_ n: Int) -&gt; Int {
      if n == 0 {
          return 1
      }
      else {
          return n * factorial(n - 1)
      }
  }
  
  print( factorial(20) )  // 2432902008176640000
  </code></pre>
  
  <p>Works as it should, as long the given number does not exceed 20, because then the result becomes too high!</p>
  
  <p>How can I circumvent this limit and thus calculate the factorial of higher numbers?</p>
  
  <p>I have searched around and found some bignum libraries for Swift. I'm doing this to learn and be familiar with Swift, therefore I want to figure this out on my own.</p>