Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<cstdio>
- // for abs function
- #include<algorithm>
- int main(){
- int a, b, sum = 0;
- scanf("%d", &a);
- b=abs(a);
- if (a>0) {
- for (int i=1; i<=a; i++){
- sum += i;
- }
- }
- if (a<0){
- for (int i=1; i<=b; i++){
- sum += i;
- sum == 1 - sum;
- }
- }
- printf("%d", sum);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment