18 lines
478 B
Plaintext
18 lines
478 B
Plaintext
function gcdp( a as uinteger, b as uinteger ) as uinteger
|
|
if b = 0 then return a
|
|
return gcdp( b, a mod b )
|
|
end function
|
|
|
|
function gcd(a as integer, b as integer) as uinteger
|
|
return gcdp( abs(a), abs(b) )
|
|
end function
|
|
|
|
function lcm(a as integer, b as integer) as uinteger
|
|
return abs(a*b)/gcd(a,b)
|
|
end function
|
|
|
|
print "lcm( 12, -18) = "; lcm(12, -18)
|
|
print "lcm( 15, 12) = "; lcm(15, 12)
|
|
print "lcm(-10, -14) = "; lcm(-10, -14)
|
|
print "lcm( 0, 1) = "; lcm(0,1)
|