title: Not Getting a Calculated Value of the Constant e
body: <p>Not really sure what the problem is here. I know I have the factorial function correct because I tested it separately. But the function that calculates e is tripping me up. All I have to do is add all the values after each factorial has been calculated. But I am having trouble translating that into C code. The problem for sure is in my second function. Any help or pointers would be appreciated.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;math.h&gt;
  
  #define NOERROR 0
  #define DECIMAL_PLACES 16
  #define EXPECTED_E 2.7182818284590452L
  
  long calcFactorial(int);
  double calcE(int);
  
  long calcFactorial(int n)
  {
      long sum = 0;
      sum = n;
  
      if(n == 0)
      {
          return 1;
      }
      else
      {
          while(n != 1)
          {
              sum = sum * (n - 1);
              n = n - 1;
          }
          printf("factorial sum: %ld\n", sum);
          return sum;
      }
  }
  
  double calcE(int n)
  {
      double e = 0;
      int counter = 0;
  
      for (counter = 0; counter &lt; DECIMAL_PLACES; counter++)
      {
          e = e + (1/calcFactorial(n));
          n--;
      } 
  
      printf("Expected e value: %0.16Lf\n", EXPECTED_E);
      printf("Calculated e value: %0.16d\n", e);
  
      return e;
  }
  
  int main()
  {
      calcE(10);
  }
  </code></pre>