#include <stdio.h>
#include <math.h>
main()
{
int i,n;
double pi;
printf("请输入n的值\n");
scanf("%d", &n);
pi = 0;
for(i = 1;i <= n;i++)
pi += 1.0 / (i*i);
pi = sqrt(6.0 * pi);
printf("pi = %lf\n", pi);
}
运行结果: