#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+Cgpkb3VibGUgY2FsY3VsYXRlX3Nlcmllc19zdW0oaW50IG4pIHsKICAgIGRvdWJsZSBzdW0gPSAwLjA7CiAgICAKICAgIGZvciAoaW50IGkgPSAxOyBpIDw9IG47IGkrKykgewogICAgICAgIHN1bSArPSAxLjAgLyAoaSAqIChpICsgMSkpOwogICAgfQogICAgCiAgICByZXR1cm4gc3VtOwp9CgppbnQgbWFpbih2b2lkKSB7CiAgICBpbnQgbjsKCiAgICBzY2FuZigiJWQiLCAmbik7CgogICAgZG91YmxlIHN1bSA9IGNhbGN1bGF0ZV9zZXJpZXNfc3VtKG4pOwoKICAgIHByaW50ZigieCglZCkgPSAlZlxuIiwgbiwgc3VtKTsKCiAgICByZXR1cm4gMDsKfQ==