Bài 1:
uses crt;
var n,i,s:longint;
begin
clrscr;
write('Nhap n: '); readln(n);
for i:=1 to n do
if i mod 2=0 then s:=s+i;
write('Tong cac so chan tu 1 den ',n,' la: ',s); writeln;
for i:=1 to n do
if (i mod 3=0) and (i mod 5=0) then write(i,' ');
readln
end.
Bài 2:
uses crt;
var n,i,s:longint;
a:array[1..1000000] of longint;
begin
clrscr;
write('Nhap n: '); readln(n);
for i:=1 to n do
begin
write('a[',i,']=');readln(a[i]);
end;
for i:=1 to n do
if a[i]<0 then write(a[i],' '); writeln;
for i:=1 to n do
if (a[i] mod 2=0) and (a[i]<>0) then s:=s+a[i];
write('Tong cac so nguyen chan la: ',s);
readln
end.