Skip to content

Commit

Permalink
taylor Series
Browse files Browse the repository at this point in the history
  • Loading branch information
maduranga98 committed Oct 1, 2022
1 parent 861a199 commit d85f6ed
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions C/Taylor Series
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <stdio.h>
#include <stdlib.h>

float Taylor_exponential(int n, float x)
{
float exp_sum = 1;
for (int i = n - 1; i > 0; --i )
exp_sum = 1 + x * exp_sum / i;
return exp_sum;
}
int main(void)
{
int n = 25;
float x = 5.0;

if (n>0 && x>0)
{
printf("value of n = %d and x = %d ", n, x );
printf("\ne^x = %f",Taylor_exponential(n,x));
}
}

0 comments on commit d85f6ed

Please sign in to comment.