Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- double expApprox(double x, int n){
- int i;
- int p=1;
- double s=1;
- for (i=1; i<=n; i++){
- p*=i;
- s+=(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