fork(2) download
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <cmath>
  4. using namespace std;
  5.  
  6. int main() {
  7. long long int n, cnt=0, i=0;
  8. scanf("%lld", &n);
  9. while(n>0) {
  10. cnt+=n+(n-1)*i;
  11. n--, i++;
  12. }
  13. printf("%lld", cnt);
  14. return 0;
  15. }
Success #stdin #stdout 0s 3300KB
stdin
3
stdout
7