-
Lenguaje
Pascal
-
Descripción
Pide 2 números enteros y calcula el mínimo común múltiplo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
program minimo_comun_multiplo;
uses crt;
var a, b, divisor : integer;
var mcm : longint;
var tecla : char;
begin
mcm := 1;
write ('Ingrese el valor de A: ');
readln (a);
write ('Ingrese el valor de B: ');
readln (b);
if a<0 then
a := -a;
if b<0 then
b := -b;
divisor := 2;
while (divisor<=a) or (divisor<=b) do
begin
while ((divisor<=a) and (a mod divisor=0)) or ((divisor<=b) and (b mod divisor=0)) do
begin
mcm := mcm * divisor;
if (divisor<=a) and (a mod divisor=0) then
a := a div divisor;
if (divisor<=b) and (b mod divisor=0) then
b := b div divisor;
end;
inc (divisor);
end;
writeln ('M'#161'nimo com'#163'n m'#163'ltiplo: ', mcm);
write (#10#13'Presione una tecla para terminar . . . ');
tecla := readkey;
end.
uses crt;
var a, b, divisor : integer;
var mcm : longint;
var tecla : char;
begin
mcm := 1;
write ('Ingrese el valor de A: ');
readln (a);
write ('Ingrese el valor de B: ');
readln (b);
if a<0 then
a := -a;
if b<0 then
b := -b;
divisor := 2;
while (divisor<=a) or (divisor<=b) do
begin
while ((divisor<=a) and (a mod divisor=0)) or ((divisor<=b) and (b mod divisor=0)) do
begin
mcm := mcm * divisor;
if (divisor<=a) and (a mod divisor=0) then
a := a div divisor;
if (divisor<=b) and (b mod divisor=0) then
b := b div divisor;
end;
inc (divisor);
end;
writeln ('M'#161'nimo com'#163'n m'#163'ltiplo: ', mcm);
write (#10#13'Presione una tecla para terminar . . . ');
tecla := readkey;
end.