fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. ios_base::sync_with_stdio(false);
  6. cin.tie(NULL);
  7. cout.tie(NULL);
  8.  
  9. long long n, m, x = 0;
  10. cin >> n >> m;
  11.  
  12. for (int i = n; i <= m; i++) {
  13. x += i;
  14. }
  15.  
  16. cout << x << endl;
  17. }
Success #stdin #stdout 0s 5320KB
stdin
2 4
stdout
9