The_Law

Untitled

Nov 27th, 2017
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.34 KB | None | 0 0
  1. include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int32_t main()
  6. {
  7.     int n, x;
  8.     cin >> n >> x;
  9.  
  10.     double ans = 0;
  11.     double p = 1;
  12.     double f = 1;
  13.  
  14.     for (int i = 1; i < n + 2; ++i)
  15.     {
  16.         ans += p / f;
  17.         p *= x;
  18.         f *= i;
  19.     }
  20.  
  21.     cout << fixed << setprecision(6) << ans;
  22.  
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment