uses crt;
var a,b,i,bcnn,ucln:integer;
begin
clrscr;
repeat
write('Nhap a='); readln(a);
write('Nhap b='); readln(b);
until (a<>0) and (b<>0);
writeln('Uoc chung cua ',a,' va ',b,' la: ');
if a<b then
begin
for i:=1 to a do
if (a mod i=0) and (b mod i=0) then write(i:4);
end;
if a>b then
begin
for i:=1 to b do
if (a mod i=0) and (b mod i=0) then write(i:4);
end;
if a=b then
begin
for i:=1 to a do
if (a mod i=0) and (b mod i=0) then write(i:4);
end;
writeln;
bcnn:=a*b;
for i:=a*b downto 1 do
if (i mod a=0) and (i mod b=0) then
begin
if bcnn>i then bcnn:=i;
end;
writeln('Boi chung nho nhat cua ',a,' va ',b,' la: ',bcnn);
ucln:=1;
for i:=1 to a*b do
if (a mod i=0) and (b mod i=0) then
begin
if ucln<i then ucln:=i;
end;
writeln('Uoc chung lon nhat cua ',a,' va ',b,' la: ',ucln);
readln;
end.