Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. // 8 zadacha
  2. #include <iostream>
  3. #include <cmath>
  4. using namespace std;
  5. long double fact(int N)
  6. {
  7.     if (N == 0)
  8.         return 1;
  9.     else
  10.         return N * fact(N - 1);
  11. }
  12.  
  13. int main()
  14. {
  15.     int x;
  16.  
  17.     int i = 2;
  18.     scanf("%i", &x);
  19.     float cnt = 1 + x;
  20.     float eps = 10;
  21.     while (cnt < eps) {
  22.         cnt = cnt + (pow(x, i) / fact(i));
  23.         i++;
  24.     }
  25.     printf("%.3f", cnt);
  26.  
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement