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

1068
Posted by omyrbai 22 May 2015 23:12
here is my code. pls help me to figure out the mistake i have made?!

program asdl;
var i,n : integer;
k : int64;
begin
 readln(n);
 k := 0;
 if n > 1 then
  for i := 1 to n do
   k := k + i;

 if n = 0 then
  k := 1;

 if n <= 0 then
  begin
   for i := 1 to -n do
     k := k + i;
   k := -k + 1;
  end;

  write(k);
end.
Re: 1068
Posted by kasarino 24 May 2015 15:38
Hi. Try to change n > 1 to n > 0  and  n <= 0 to n < 0

Edited by author 24.05.2015 15:42