Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * prog.c
- *
- * Created on: 23 сент. 2016 г.
- * Author: Админ
- */
- #include <stdio.h>
- #include <math.h>
- double expApprox(double x, int n){
- int i, k;
- int p=1;
- double s=0;
- for (i=1; i<=n; i=i+2){
- if (i==1) p=i;
- else p*=((i-1)*i);
- k=pow(-1,i/2);
- s+=(k*pow(x,i)/p);
- }
- return s;
- }
- int main(){
- int n;
- double x;
- scanf("%lf %i", &x, &n);
- printf("%f", expApprox(x, n));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement