Bài 1:
Program bt1;
Uses crt;
Var S,d,i,N: integer;
begin
clrscr;
wrileln(' Nhap gia trị n: '); readln(n);
d:=0;
S:=0;
for i:= 1 to n do if i mod 3 = 0 then
begin
S:=S+i;
writeln(' Tong cac so chia het cho 2: ');
readln(S);
d:=d+1;
writeln(' Co ' d ' chia het cho 2 ',d );
Readln
End;
End.
Bài 2:
Program bt2;
Uses crt;
Var n,i,d,N: integer;
Begin
clrscr;
writeln(' Nhap n: '); readln(n);
d:=0;
S:=0;
for i:=1 to N do if mod 4 = 0 then
begin
S:=S*i;
Writeln(' Tich cac so chia het cho 4: ');
readln(S);
d:=d+1;
Writeln('Co ' d ' chia het cho 4 ',d);
Readln(d);
End;
readln
end.
Bài 3:
Program bt3;
Uses crt;
Var i,n,tong: integer;
tbc: real;
begin
clrscr;
write(' nhap gia tri n: '); readln(n);
tong:=0;
i:=1;
while i <=n do
begin
tong:= tong+i;
i:=i+1;
end;
tbc:=tong/n;
writeln(' trung binh cong la: ',tbc);
readln
end.