Program Tinh_tong_so_le;
Uses CRT;
Var i,n,S:integer;
sl:boolean;
Begin
Clrscr;
Write('Nhap so n:');Readln(n);
sl:=True;
For i:=1 to n do
Begin
If sl=True then S:=S+i;
sl:= not True;
End;
Writeln('Tong cua n so le la:', S);
Readln;
End.
@xin ctlhn
2
Program Tinh_tong_so_chan;
Uses CRT;
Var i,n,S:integer;
sl:boolean;
Begin
Clrscr;
Write('Nhap so n:');Readln(n);
sl:=True;
For i:=1 to n do
Begin
If sl=True then S:=S+i;
sl:= not True;
End;
Writeln('Le cua n so le la:', S);
Readln;
End.