Skip to content

Instantly share code, notes, and snippets.

@AnthonyMikh
Created January 20, 2018 10:17
Show Gist options
  • Save AnthonyMikh/e3a042e91d10b8169372271ceb80e434 to your computer and use it in GitHub Desktop.
Save AnthonyMikh/e3a042e91d10b8169372271ceb80e434 to your computer and use it in GitHub Desktop.
Решение задачи №63 от UniLecs
--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
@AnthonyMikh
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment