Advertisement
STANAANDREY

getE

Dec 10th, 2019
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.24 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int getE()
  5. {
  6.     int n, e = 0;
  7.     cout << "n=";cin >> n;
  8.     for (int x = 1; x <= n; x++)
  9.         e += (3 * x - 2);
  10.  
  11.     return e;
  12. }
  13.  
  14. int main()
  15. {
  16.     cout << getE();
  17.     return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement