Created
January 20, 2018 10:17
-
-
Save AnthonyMikh/e3a042e91d10b8169372271ceb80e434 to your computer and use it in GitHub Desktop.
Решение задачи №63 от UniLecs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--gcd=greatest common divisor | |
gcd' x y | |
| x < y = gcd' y x | |
| x == y = x | |
| otherwise = let x' = x - y in x' `seq` gcd' x' y | |
--lcm=least common divisor | |
lcm' x y = | |
let prod = x*y | |
in prod `seq` prod `div` gcd' x y | |
main = putStrLn . show $ lcm' 6 4 --12 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Playground: https://repl.it/repls/FlashyPassionateStallion