title: Why does my Euler's number program always print 2.00000?
body: <p>This C Program should calculate Euler's number up to a certain point. it will calculate as long as the difference of  1/(n-1)!  - 1/n! is smaller than the number the user entered.</p>
  <p>The problem : no matter what number I enter it says that the Euler's number is 2.000000.</p>
  <p>I think it is because it leaves the do while loop after the first time, I think that is because 1 - 1 equals 0 and therefore it is smaller than the number the user entered, I have already tried to stop this by adding the condition eul == 2, but when I run the program with this condition it does not work at all.</p>
  <p>Here is my program:</p>
  <pre><code>#include &lt;stdio.h&gt;
  
  float scanningTheDifference();
  float calculatingTheEuclidianNumber(float d);
  int calculatingFaculty(int i, int z);
  
  void main () {
      char answer;
      float d;
      double eul;
      printf (&quot;calculating the euclidian number\n&quot;);
  
      do {
          d = scanningTheDifference(); 
          eucl = calculatingTheEuclidianNumber(d);
  
          printf (&quot;\n the euclidian number is: %lf&quot;, eucl);
  
          do {
              printf(&quot;\n \n do you want to repeat? (j/n)&quot;);
              fflush(stdin);
              scanf(&quot;%c&quot;, &amp;answer);
          } while (answer != 'y' &amp;&amp; answer != 'n');
      } while (answer == 'y');
  }
  
  float scanningTheDifference() {
      float d;                   //difference
      
      do {
          printf(&quot;\n please enter the difference of two numbers, it has to be positive: &quot;);
          scanf(&quot;%f&quot;, &amp;d);
      } while (d &lt; 0);
  
      return d;
  }
  
  float calculatingTheEuclidianNumber(float d) {
      double num1, num2;
      double eucl = 0.0;
      int i = 1;
      int z = 1;
  
      do {
          num1 = 1 / i;
          i = calculatingFaculty(i, z);
          z++;
          num2 = 1 / i;
          i = calculatingFaculty(i, z);
          z++;
          eucl = eucl + num1 + num2;
      } while (num1 - num2 &lt; d);
  
      return eucl;
  }
  
  int calculatingFaculty(int i, int z) {
      int res;
  
      res = i * z;
  
      return res;
  }
  </code></pre>