Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- int main()
- {int n;
- double eps, r, s, x,f;
- printf ("eps=");
- scanf ("%lf%lf", &eps,&x);
- n=0;
- r=1+log(3)*x;
- s=0;
- f=1;
- if (x<=0 || x>=1){
- printf("0<=x<=1 !!!!");
- return 0
- ;}
- while (fabs(r) > eps)
- {
- s+=r;
- printf("s=%.1lf\n",s);
- n++;
- printf("n=%d\t",n);
- r*=(log(3)*x)/(n*(n+1));
- printf("r=%lf\t",r);
- f*=3*x;
- printf("f=%lf\t",f);
- }
- printf("s=%lf\n x=%.1lf f=%.1lf", s ,x,f);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement