求圆周率的值为什么错了
#include<stdio.h>double fun(double eps)
{
double s=1.0,sum=1.0;
int n=1;
while(s>=eps)
{
s*=n/(2*n+1);
sum+=s;
n++;
}
return 2*sum;
}
main()
{
double x;
printf("请输入eps:");
scanf("%lf",&x);
printf("\neps=%lf,PI=%lf\n",x,fun(x));
}
fun功能是求π的值,输入精度eps=0.0005后结果应该得出π的值。可为什么我运行后得出PI=2.000000?到底哪出错了,求解