Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include "pch.h"
  2. #include <iostream>
  3. #include <cmath>
  4.  
  5. using namespace std;
  6.  
  7. int Factorial(int i) {
  8.     int sum = 0;
  9.     for (int x = 1; x <= i; x++)
  10.         sum += i;
  11.     return sum;
  12. }
  13.  
  14. double Element(int i, int x) {
  15.     return pow(x, i) / Factorial(i);
  16. }
  17.  
  18. int main()
  19. {
  20.     setlocale(LC_ALL, "rus");
  21.     int n, x;
  22.     double sum = 0;
  23.     cout << "x = "; cin >> x;
  24.     cout << "N = "; cin >> n;
  25.     for (int i = 1; i <= n; i++)
  26.         sum += Element(x, i);
  27.     cout << "Сумма ряда до " << n << " члена равна " << sum << endl;
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement