Advertisement
Dora-goha

Untitled

Jan 8th, 2020
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.46 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4. int main()
  5. {int n;
  6. double eps, r, s, x,f;
  7. printf ("eps=");
  8. scanf ("%lf%lf", &eps,&x);
  9. n=0;
  10. r=1+log(3)*x;
  11. s=0;
  12. f=1;
  13. if (x<=0 || x>=1){
  14.  printf("0<=x<=1 !!!!");
  15.  return 0
  16. ;}
  17.  
  18. while (fabs(r) > eps)
  19. {
  20. s+=r;
  21. printf("s=%.1lf\n",s);
  22. n++;
  23. printf("n=%d\t",n);
  24. r*=(log(3)*x)/(n*(n+1));
  25. printf("r=%lf\t",r);
  26. f*=3*x;
  27. printf("f=%lf\t",f);
  28. }
  29. printf("s=%lf\n x=%.1lf f=%.1lf", s ,x,f);
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement