Least common multiple: Difference between revisions
Content added Content deleted
(GP) |
|||
Line 323: | Line 323: | ||
} |
} |
||
</lang> |
</lang> |
||
=={{header|Lua}}== |
|||
<lang lua>function gcd( m, n ) |
|||
while n ~= 0 do |
|||
local q = m |
|||
m = n |
|||
n = q % n |
|||
end |
|||
return m |
|||
end |
|||
function lcm( m, n ) |
|||
return ( m ~= 0 and n ~= 0 ) and m * n / gcd( m, n ) or 0 |
|||
end |
|||
print( "Erg: ", lcm(12,18) )</lang> |
|||
=={{header|PARI/GP}}== |
=={{header|PARI/GP}}== |