Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- double sum (int k, double x)
- {
- int i;
- unsigned int h;
- double s, o;
- s = 0;
- o = 1;
- h = 1;
- for (i=0; i<=k;i++)
- {
- if (i) h *= i;
- s += o / h;
- o *= x;
- }
- return(s);
- }
- int main(void)
- {
- int n;
- double h, res;
- scanf_s("%d", &n);
- scanf_s("%lf", &h);
- res = sum(n, h);
- printf("%f", res);
- return(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement