Advertisement
H-a-y-K

Untitled

Dec 28th, 2020
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. using namespace std;
  5.  
  6. double fact(int n) {
  7.     double x = 1;
  8.  
  9.     for (int i = 1; i <= n; ++i) {
  10.         x *= i;
  11.     }
  12.  
  13.     return x / (n + 1);
  14. }
  15.  
  16. int main()
  17. {
  18.     double sum=0;
  19.  
  20.     for (int i = 1; i <= 10; ++i) {
  21.         sum += fact(i);
  22.     }
  23.  
  24.     cout << setprecision(3*10) << sum << endl;
  25.  
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement