fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6. int x,y=0;
  7. cin>>x;
  8. while(x!=1){
  9. y=y+x;
  10. if(x<=0){x++;}
  11. else{x--;}
  12.  
  13.  
  14. }
  15. cout<<y+1;
  16. return 0;
  17. }
Success #stdin #stdout 0s 15240KB
stdin
-2
stdout
-2