title: Taylor Series in C
body: <p>I'm trying to make a program to calculate the cos(x) function using taylor series so far I've got this:</p>
  
  <pre><code>int factorial(int a){
  
  if(a &lt; 0)
      return 0;
  else if(a==0 || a==1)
      return 1;
  else
      return a*(factorial(a-1));
  }
  
  double Tserie(float angle, int repetitions){
      double series = 0.0;
      float i;
  
  for(i = 0.0; i &lt; repeticiones; i++){
      series += (pow(-1, i) * pow(angle, 2*i))/factorial(2*i);
      printf("%f\n", (pow(-1, i) * pow(angle, 2*i))/factorial(2*i));
  }
  return series;
  </code></pre>
  
  <p>}</p>
  
  <p>For my example I'm using angle = 90, and repetitions = 20, to calculate cos(90) but it's useless I just keep getting values close to the infinite, any help will be greatly appreciated.</p>