The result of my program differs from the result of the implementation in the paper, where is the error?
I want to calculate this: -1+2-3+4-5+...+ or - N, in PASCAL language, so i write this program but the result is false, Although the method of implementation in the paper is correct.
So, for example, if I enter the number 4, the result is supposed to be 2, but it prints 10 for me, so where is the error? :
S:= N mod 2;
while i<= N do begin
if S=1 then begin Y:=Y-I;
else begin Y:=Y+I;