title: Calculating sin(x) with Taylor series
body: <blockquote>
  <p><strong>Task:</strong> According to the Taylor Series of sin(x) calculate with using a double function named <strong>mysin</strong> pass it to a double variable. Take a x value from user and use the mysin function to calculate sin(x).</p>
  <p><a href="https://i.stack.imgur.com/elqSV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/elqSV.png" alt="Sin()x Tyler Series Formula" /></a></p>
  </blockquote>
  <p>Problem is program gives me wrong value of sin(x). I have been trying to solve that issue about 4 hours but couldn't find it. Is it because of sin(x) function or have I missed something in my code?</p>
  <p><strong>My Code:</strong></p>
  <pre><code>#include &lt;stdio.h&gt;
  
  double mysin(double x)
  {
      double value = x;
      double sum = x;
      int neg_pos = 1;
      int fac = 1;
      
      int counter = 0;
      
      while(1)
      {
          neg_pos *= -1;
          fac += 2;
          
          value = value/(fac*(fac-1));
          value = value*x*x*neg_pos;
  
          sum += value;
          
          //printf(&quot;Hello&quot;);
          counter++;
          if (counter == 100) break;
      }
      return sum;
  }
  
  int main()
  {
      double number;
      scanf(&quot;%lf&quot;,&amp;number);
      printf(&quot;%g&quot;,mysin(number));
      //printf(&quot;%g&quot;,number);
  }
  </code></pre>