Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. include <iostream>
  2. using namespace std;
  3.  
  4. // Dado um inteiro n, encontre a soma da série 1+(2*3)+(4*5*6)+...+ n.
  5.  
  6. int main() {
  7.  
  8. int i, n, t=0, soma=0, resp=0;
  9. cout<< "Entre com um valor n inteiro: ";
  10. cin>> n;
  11. for (i = 1; i <= n; i++) {
  12. t += i;
  13. soma += (t*i);
  14. }
  15. resp=soma;
  16. cout<<"A soma da sequencia e: "<< soma;
  17. return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement