fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. double ATAN(double x);
  5.  
  6. int main(){
  7. double a;
  8. a = 4*(4 * ATAN(1.0/5.0) - ATAN( 1.0 / 239.0));
  9. printf("%.11lf", a);
  10.  
  11. return 0;
  12. }
  13.  
  14. double ATAN(double x){
  15. double y;
  16. double t, s;
  17. int n;
  18.  
  19. y = x;
  20. t = x;
  21. n = 3;
  22. while( 1 ){
  23. t = - t*x*x;
  24. s = t/n;
  25. if(fabs(s) < 0.000000000001) break;
  26. y = y + s;
  27. n++; n++;
  28. }
  29. return y;
  30. }
Success #stdin #stdout 0.01s 1720KB
stdin
Standard input is empty
stdout
3.14159265359