2 câu trả lời
uses crt;
var a, b, c, uc, bc, i, m: longint;
begin
clrscr;
write ('nhap a: '); readln (a);
write ('nhap b: '); readln (b);
write ('nhap c: '); readln (c);
m:=a;
if m>b then m:=b;
if m>c then m:=c;
uc:=1;
for i:=1 to m do
if (a mod i= 0) and (b mod i= 0) and (c mod i= 0) then
begin
if uc<i then uc:=i;
end;
bc:=a*b*c;
for i:=a*b*c downto 1 do
if (i mod a= 0) and (i mod b= 0) and (i mod c= 0) then
begin
if bc>i then bc:=i;
end;
writeln ('Uoc Chung Lon Nhat: ',uc);
writeln ('Boi Chung Nho Nhat: ',bc);
readln;
end.
var a, b, c, uc, bc, i, m: longint;
begin
clrscr;
write ('nhap a: '); readln (a);
write ('nhap b: '); readln (b);
write ('nhap c: '); readln (c);
m:=a;
if m>b then m:=b;
if m>c then m:=c;
uc:=1;
for i:=1 to m do
if (a mod i= 0) and (b mod i= 0) and (c mod i= 0) then
begin
if uc<i then uc:=i;
end;
bc:=a*b*c;
for i:=a*b*c downto 1 do
if (i mod a= 0) and (i mod b= 0) and (i mod c= 0) then
begin
if bc>i then bc:=i;
end;
writeln ('Uoc Chung Lon Nhat: ',uc);
writeln ('Boi Chung Nho Nhat: ',bc);
readln;