ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1068. Sum

PASCAL AC Solution 9 lines!!!!
Posted by George Skhirtladze 13 Apr 2010 16:40
var n,i:longint;
begin
read(n);
if n<=0 then begin
n:=n*-1;
write(((n*(n+1))div 2)*-1+1);
end
else writeln(n*(n+1)div 2);
end.

Edited by author 13.04.2010 16:42

Edited by author 13.04.2010 16:43
Your solution too big!
Posted by AterLux 8 Sep 2010 19:59
Use single formula, without 'if'-condition. Hint: Use Abs()