Advertisement
Guest User

work_2_mission_4

a guest
Dec 9th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. double power(double a, double b)
  5. {
  6.     double i, res = 1;
  7.     for (i = 0; i < b; i++)
  8.     {
  9.         res = res*a;
  10.     }
  11.     return res;
  12. }
  13.  
  14. double azeret(double a)
  15. {
  16.     double res =1 , i;
  17.     for (i = 1; i <= a; i++)
  18.     {
  19.         res = res*i;
  20.     }
  21.     return res;
  22. }
  23.  
  24.  
  25. int main()
  26. {
  27.     double n, x, i, sum = 0;
  28.     cout << "Enter N: ";
  29.     cin >> n;
  30.     cout << "Enter X: ";
  31.     cin >> x;
  32.  
  33.     sum = 1 + x;
  34.     cout << "1 + " << x;
  35.     for (i = 2; i < n; i++) {
  36.         cout << "+";
  37.         cout << power(x, i) << "/" << azeret(i);
  38.         sum = sum + power(x, i) / azeret(i);
  39.     }
  40.     cout << "=" << sum;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement