|
|
back to boardDiscussion of Problem 1068. SumShow all messages Hide all messagesGreetings to all. I want to learn that such here with a problem number 1068, I all have correctly written that kompiliator from me demands, tell please. Here the *_Pascal_* language program: ___________________________________________ var s,i,n:integer; BEGIN s:=0; read(n); if (n>=0) then for i:=1 to N do s:=s+i; if (n<=0) then for i:=-1 downto N do s:=s+i; Writeln(s); END. ___________________________________________ You need calculate sum between 1 and N. So, if n<=0, you should sum 1,0,-1,-2,...N. But not -1,-2,...-N. |
|
|