Advertisement
Kaidul

B

Jan 30th, 2013
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.29 KB | None | 0 0
  1. #include <cstdio>
  2. #include <iostream>
  3.  
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.     int n, i;
  9.     long long sum;
  10.     while(cin >> n) {
  11.         sum = 0;
  12.         for(i = 0; i < (n-1); i++) sum += ((n-i-1) + i * (n-i-1));
  13.         sum += n;
  14.         cout << sum << "\n";
  15.     }
  16.     return 0;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement