BÀI 1:
var n,i,j,k,sum,dem,tong:longint;
a:array [1..1000] of longint;
begin
k:=0;
read(n);
for i:=1 to n-1 do
begin
sum:=i;
for j := i+1 to n-1 do
begin
if (sum<n) then sum:=sum+j
else if (sum>n) then begin sum :=0; break; end
else if (sum = n) then begin k:=k+1; a[k]:=j; break; end;
end;
end;
if k=0 then write('Khong the bieu dien');
for i:=1 to k do
begin
tong:=0;
while tong<n do
begin
dec(a[i]);
tong:=tong+a[i];
end;
end;
for i:=1 to k do
begin
tong:=0;
while tong<n do
begin
write(a[i],' ');
inc(a[i]);
tong:=tong+a[i];
end;
writeln;
end;
readln;
end.
BÀI 2:
var n,i,dem:longint;
function checkprime(i:longint):boolean;
var c:longint;
begin
if i=1 then exit(false);
if i=2 then exit(true);
for c:=2 to trunc(sqrt(n)) do if i mod c = 0 then exit(false) else exit(true);
end;
begin
read(n);
while dem<n do
begin
if checkprime(inc(i)) then write(i,' ');
inc(dem);
end;
readln;
end.