Advertisement
Grugaloragran

Untitled

Oct 7th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.35 KB | None | 0 0
  1. #include <stdio.h>
  2. double sum (int k, double x)
  3. {
  4.     int i;
  5.     unsigned int h;
  6.     double s, o;
  7.         s = 0;
  8.         o = 1;
  9.         h = 1;
  10.     for (i=0; i<=k;i++)
  11.     {
  12.         if (i) h *= i;
  13.         s += o / h;
  14.         o *= x;
  15.     }
  16.     return(s);
  17. }
  18. int main(void)
  19. {
  20.     int n;
  21.     double h, res;
  22.     scanf_s("%d", &n);
  23.     scanf_s("%lf", &h);
  24.     res = sum(n, h);
  25.     printf("%f", res);
  26.     return(0);
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement