Bài 1:
program tinhtong;
uses crt;
var i,s:integer;
begin
clrscr;
S:=0;
for i:=1 to 15 do S:=S+i;
write('Tong cac so tu 1 den 15 la: ',s);
readln;
end.
Bài 2:
program giaithua;
uses crt;
var n,i:byte;
gt:int64;
begin
clrscr;
write('Nhap so can tinh: '); readln;
gt:=1;
for i:=1 to n do gt:=gt*i;
write(n,'!= ',gt);
readln;
end.
Bài 3:
program tinhtong;
uses crt;
var i,s:integer;
begin
clrscr;
S:=0;
for i:=1 to 20 do
if i mod 2=1 then S:=S+i;
write('Tong cac so le tu 1 den 20 la: ',s);
readln;
end.
Bài 4:
program tinhtong;
uses crt;
var i,s:integer;
begin
clrscr;
S:=0;
for i:=1 to 20 do
if i mod 2=0 then S:=S+i;
write('Tong cac so chan tu 1 den 20 la: ',s);
readln;
end.