Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- int n, i;
- float p, c, sum = 0, e = 0.001, x;
- double func(float x, int n)
- {
- return (x + n) / powf(x, n);
- }
- int main(void)
- {
- scanf("%f", &x);
- n = 1;
- c = func(x, n);
- sum += c;
- n++;
- do
- {
- p = c;
- c = func(x, n);
- sum += c;
- n++;
- } while (abs(c - p) > e);
- printf("%f\n", sum);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement