Lucian_Adrian

#338 Expresie5

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