#include <stdio.h>
#include <math.h>
double x(int n) {
double sum = 1.0;
int i;
for (i = 1; i < n; i++) {
sum
+= pow(-1, i
) / (2 * i
+ 1); }
return 4 * sum;
}
int main() {
int n1 = 3, n2 = 10;
printf("x(%d) = %lf\n", n1
, x
(n1
)); printf("x(%d) = %lf\n", n2
, x
(n2
)); return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxtYXRoLmg+Cgpkb3VibGUgeChpbnQgbikgewogICAgZG91YmxlIHN1bSA9IDEuMDsgCiAgICBpbnQgaTsKICAgIGZvciAoaSA9IDE7IGkgPCBuOyBpKyspIHsgCiAgICAgICAgc3VtICs9IHBvdygtMSwgaSkgLyAoMiAqIGkgKyAxKTsgCiAgICB9CiAgICByZXR1cm4gNCAqIHN1bTsKfQoKaW50IG1haW4oKSB7CiAgICBpbnQgbjEgPSAzLCBuMiA9IDEwOwogICAgcHJpbnRmKCJ4KCVkKSA9ICVsZlxuIiwgbjEsIHgobjEpKTsKICAgIHByaW50ZigieCglZCkgPSAlbGZcbiIsIG4yLCB4KG4yKSk7CiAgICByZXR1cm4gMDsKfQo=