Least common multiple: Difference between revisions
Content added Content deleted
(→{{header|Run BASIC}}: Post corrected) |
Not a robot (talk | contribs) (Add CLU) |
||
Line 934: | Line 934: | ||
(defn lcmv [& v] (reduce lcm v)) |
(defn lcmv [& v] (reduce lcm v)) |
||
</lang> |
</lang> |
||
=={{header|CLU}}== |
|||
<lang clu>gcd = proc (m, n: int) returns (int) |
|||
m, n := int$abs(m), int$abs(n) |
|||
while n ~= 0 do m, n := n, m // n end |
|||
return(m) |
|||
end gcd |
|||
lcm = proc (m, n: int) returns (int) |
|||
if m=0 cor n=0 |
|||
then return(0) |
|||
else return(int$abs(m*n) / gcd(m,n)) |
|||
end |
|||
end lcm |
|||
start_up = proc () |
|||
po: stream := stream$primary_output() |
|||
stream$putl(po, int$unparse(lcm(12, 18))) |
|||
end start_up</lang> |
|||
{{out}} |
|||
<pre>36</pre> |
|||
=={{header|COBOL}}== |
=={{header|COBOL}}== |