Advertisement
josiftepe

Untitled

Sep 28th, 2021
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.32 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std ;
  3.  
  4. int main() {
  5.     int n;
  6.     cin >> n;
  7.     int faktoriel = 1;
  8.     double P = 0.0;
  9.     int tmp_n = n;
  10.     for(int i = 1; i <= n; i++) {
  11.         faktoriel *= i;
  12.         P += ((double) faktoriel / (double) tmp_n);
  13.         tmp_n--;
  14.     }
  15.     cout << P << endl;
  16.     return 0;
  17. }
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement