uses crt;
var a,b:integer;
{--------------------------chuong-trinh-con-tim-ucln-------------------------}
function ucln(x,y:integer):integer;
var i:integer;
begin
ucln:=1;
if x>y then
begin
for i:=1 to y do
if (x mod i=0) and (y mod i=0) then
begin
if ucln<i then ucln:=i;
end;
end
else if x=y then ucln:=x
else
begin
for i:=1 to x do
if (x mod i=0) and (y mod i=0) then
begin
if ucln<i then ucln:=i;
end;
end;
end;
{----------------------chuong-trinh-chinh--------------------------}
begin
clrscr;
repeat
write('Nhap a='); readln(a);
write('Nhap b='); readln(b);
until (a>0) and (b>0);
writeln(ucln(a,b));
readln;
end.