title: Recursive function calculating factorials leads to stack overflow
body: <p>I tried a recursive factorial algorithm in Rust. I use this version of the compiler:</p>
  
  <pre><code>rustc 1.12.0 (3191fbae9 2016-09-23)
  cargo 0.13.0-nightly (109cb7c 2016-08-19)
  </code></pre>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>extern crate num_bigint;
  extern crate num_traits;
  
  use num_bigint::{BigUint, ToBigUint};
  use num_traits::One;
  
  fn factorial(num: u64) -&gt; BigUint {
      let current: BigUint = num.to_biguint().unwrap();
      if num &lt;= 1 {
          return One::one();
      }
      return current * factorial(num - 1);
  }
  
  fn main() {
      let num: u64 = 100000;
      println!("Factorial {}! = {}", num, factorial(num))
  }
  </code></pre>
  
  <p>I got this error:</p>
  
  <pre class="lang-none prettyprint-override"><code>$ cargo run
  
  thread 'main' has overflowed its stack
  fatal runtime error: stack overflow
  error: Process didn't exit successfully
  </code></pre>
  
  <p>How to fix that? And why do I see this error when using Rust?</p>