#include <stdio.h>
double calculate_series_sum(int n) {
double sum = 0.0;
for (int i = 1; i <= n; i++) {
sum += 1.0 / (i * (i + 1));
}
return sum;
}
int main(void) {
int n;
double sum = calculate_series_sum(n);
printf("x(%d) = %f\n", n
, sum
);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiAKZG91YmxlIGNhbGN1bGF0ZV9zZXJpZXNfc3VtKGludCBuKSB7CiAgICBkb3VibGUgc3VtID0gMC4wOwogCiAgICBmb3IgKGludCBpID0gMTsgaSA8PSBuOyBpKyspIHsKICAgICAgICBzdW0gKz0gMS4wIC8gKGkgKiAoaSArIDEpKTsKICAgIH0KIAogICAgcmV0dXJuIHN1bTsKfQogCmludCBtYWluKHZvaWQpIHsKICAgIGludCBuOwogCiAgICBzY2FuZigiJWQiLCAmbik7CiAKICAgIGRvdWJsZSBzdW0gPSBjYWxjdWxhdGVfc2VyaWVzX3N1bShuKTsKIAogICAgcHJpbnRmKCJ4KCVkKSA9ICVmXG4iLCBuLCBzdW0pOwogCiAgICByZXR1cm4gMDsKfQ==