program mcdmcm;
uses crt;
var a,b,mcd,mcm:integer;
function mmccdd(x,y:integer):integer;
begin
if (x=y) then
mmccdd:=x
else
begin
if (x>y) then
mmccdd:=mmccdd(x-y,y)
else
mmccdd:=mmccdd(x,y-x)
end;
end;
function mmccmm(x,y:integer):integer;
begin
mmccmm:=(x div mmccdd(x,y))*y;
end;
procedure espera;
var c:char;
begin
repeat
c:=readkey;
until c=chr(27);
end;
begin
clrscr;
write('a? ');readln(a);
write('b? ');readln(b);
mcd:=mmccdd(a,b);
mcm:=mmccmm(a,b);
writeln(' mcd = ',mcd);
writeln(' mcm = ',mcm);
espera;
end.
No hay comentarios:
Publicar un comentario