Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int n, summa=0;
- cin >> n;
- if (n>0) {
- for (int i = 1; i<=n; i++) {
- summa+=i;
- }
- }
- if (n<=0) {
- for (int i=1; i>=n; i--) {
- summa+=i;
- }
- }
- cout << summa;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement