Advertisement
josiftepe

Untitled

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