Advertisement
RadioNurshat

Shifting Series

Sep 30th, 2020
1,176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.28 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. using namespace std;
  4. int main()
  5. {
  6.     int n = 0;
  7.     cin >> n;
  8.     int left = 1;
  9.     int middle = 2;
  10.     int right = 3;
  11.     int series = 1*2;
  12.     while (right < 2 * n) {
  13.         left++;
  14.         middle++;
  15.         right++;
  16.         series += left * middle * right;
  17.     }
  18.     cout << series << endl;
  19. }
  20.  
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement