mahatma_xande

ex07lista05

Aug 22nd, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.35 KB | None | 0 0
  1. /*
  2. It calculates the sum of the first n terms of a series with factorials in its denominator.
  3. */
  4.  
  5. #include <stdio.h>
  6.  
  7. int main(){
  8.  
  9.     int n, w = 1, k = 1;
  10.     float e = 1;
  11.  
  12.     printf("Enter n: ");
  13.     scanf("%d", &n);
  14.  
  15.     while(k <= n){
  16.         w = w*k;
  17.         e = e + 1.0/(w);
  18.         k = k + 1;
  19.     }
  20.  
  21.     printf("%f\n", e);
  22. }
Advertisement
Add Comment
Please, Sign In to add comment