Input eps : 0.0005
eps = 0.000500, PI/2 = 1.570553
Press any key to continue
*/
#include <stdio.h>
#include <math.h>
double fun(double eps) {
double m = 1.0,n = 1.0,t = 1.0,sum = 1.0;
int i;
for(i = 1;t >= eps; ++i) {
m *= i;
n *= 2 * i + 1;
t = m/n;
sum += t;
}
return sum;
}
int main() {
double x;
// void NONO();
printf("Input eps : ");
scanf("%lf",&x);
printf("\neps = %lf, PI/2 = %lf\n", x, fun(x));
// NONO();
return 0;
}