fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4.  
  5. int main() {
  6. int n, res = 2;
  7. cin >> n;
  8.  
  9. if (n == 0) {
  10. cout << 0;
  11. } else {
  12. for (int i = 2; i <= n; i++) {
  13. res += i;
  14. }
  15.  
  16. cout << res;
  17. }
  18.  
  19. return 0;
  20. }
Success #stdin #stdout 0s 5312KB
stdin
1
stdout
2