Bài 1 :
Program BT_1;
Var n,dem,i,j,t,d : longint;
Begin
repeat
Write ('Nhap N : ');Readln(n);
until n > 0 ;
dem := 0;
t := 0;
i := 0;
d := 0;
While dem <> n do
Begin
i := i + 1;
For j := 1 to i do If i mod j = 0 then d := d+ 1;
If d = 2 then
Begin
t := t + i;
dem := dem + 1;
end;
d := 0;
end;
Writeln('1.Tong cua ',n,' so nguyen to la : ',t);
end.
Bài 2 :
Program BT_2;
Var n,i,t : longint;
a : array [1..100] of longint;
Begin
repeat
Write ('Nhap N : ');Readln(n);
until n > 0 ;
t := 0;
For i := 1 to n do
Begin
Write ('A[',i,']= ');Readln(A[i]);
If a[i] mod 3 = 0 then t := t + a[i];
end;
Write ('2.Tong cac so chia het cho 3 la : ',t);
end.
Bài 3 :
Program BT_3;
Var n,i,max : longint;
a : array [1..100] of longint;
Begin
repeat
Write ('Nhap N : ');Readln(n);
until n > 0 ;
For i := 1 to n do
Begin
Write ('A[',i,']= ');Readln(A[i]);
end;
max := a[1];
For i := 1 to n do If A[i] > max then max := A[i];
Write ('3.Max la : ',max);
end.