Bài 1 :
uses crt;
var i, n, TTS : integer;
begin
clrscr;
write('Nhap so n : '); readln(n);
TTS := 0; for i := 1 to n do
TTS := TTS + i;
write('TTS = ', TTS);
readln
end.
Câu 2 :
uses crt;
var i, n, S : integer;
begin
clrscr;
write('Nhap so n : '); readln(n);
S := 0; for i := 1 to n do
if i mod 2 <> 0 then S := S + i;
write('TTS = ', TTS);
readln
end.
Câu 3 :
uses crt;
var i, n, TTS : integer;
begin
clrscr;
write('Nhap so n : '); readln(n);
TTS := 0; for i := 1 to n do
if i mod 2 = 0 then TTS := TTS + i;
write('TTS = ', TTS);
readln
end.