Lucian_Adrian

#336 Expresie4

Sep 21st, 2021
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.21 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6.  
  7. {
  8.  
  9. long int n, S=0,i;
  10.  
  11. cin >> n;
  12.  
  13. for (i=1; i<=n; ++i)
  14.  
  15. S = S + i * (n-i+1);
  16.  
  17. cout << "Rezultatul este " << S << endl;
  18.  
  19. }
Advertisement
Add Comment
Please, Sign In to add comment