Least common multiple: Difference between revisions
Content added Content deleted
m (→{{header|TXR}}: Typo.) |
|||
Line 144: | Line 144: | ||
=={{header|AppleScript}}== |
=={{header|AppleScript}}== |
||
<lang AppleScript>-- |
<lang AppleScript>-- LEAST COMMON MULTIPLE ----------------------------------------------------- |
||
-- lcm :: Integral a => a -> a -> a |
|||
on lcm(x, y) |
on lcm(x, y) |
||
if x = 0 or y = 0 then |
if x = 0 or y = 0 then |
||
Line 154: | Line 156: | ||
-- TEST ---------------------------------------------------------------------- |
|||
-- TEST |
|||
on run |
on run |
||
Line 162: | Line 164: | ||
end run |
end run |
||
-- GENERIC FUNCTIONS --------------------------------------------------------- |
|||
-- GENERAL FUNCTIONS |
|||
-- abs :: Num a => a -> a |
-- abs :: Num a => a -> a |
||
Line 176: | Line 177: | ||
-- gcd :: Integral a => a -> a -> a |
-- gcd :: Integral a => a -> a -> a |
||
on gcd(x, y) |
on gcd(x, y) |
||
script |
script |
||
on |
on |λ|(a, b) |
||
if b = 0 then |
if b = 0 then |
||
a |
a |
||
else |
else |
||
|λ|(b, a mod b) |
|||
end if |
end if |
||
end |
end |λ| |
||
end script |
end script |
||
result's |λ|(abs(x), abs(y)) |
|||
end gcd</lang> |
end gcd</lang> |
||
{{Out}} |
{{Out}} |
||
<lang AppleScript>36</lang> |
<lang AppleScript>36</lang> |