Tham khảo:
Program BTH;
uses crt;
var i,n,s:longint;
Begin
clrscr;
write('Nhap n: ');readln(n);
i:=1;
While i<>n do
Begin
If i mod 2=0 then s:=s+i;
i:=i+1;
end;
writeln('Tong day so tren la: ',s);
readln;
end.
program tinh_tong_chan;
uses crt;
Var i,N,S: integer;
begin
clrscr;
writeln('nhap so n');
readln(N);
S:=0;
i:=1;
while i <= N do
begin
S:=S+i;
i:=i+1;
end;
Writeln('tong la: ',S);
readln;
end.
đây bạn nha