RosettaCodeData/Task/Least-common-multiple/Cowgol/least-common-multiple.cowgol
2023-07-01 13:44:08 -04:00

21 lines
366 B
Text

include "cowgol.coh";
sub gcd(m: uint32, n: uint32): (r: uint32) is
while n != 0 loop
var t := m;
m := n;
n := t % n;
end loop;
r := m;
end sub;
sub lcm(m: uint32, n: uint32): (r: uint32) is
if m==0 or n==0 then
r := 0;
else
r := m*n / gcd(m,n);
end if;
end sub;
print_i32(lcm(12, 18));
print_nl();