Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save AnthonyMikh/b2c2647c8358e38626679610a5ff8770 to your computer and use it in GitHub Desktop.
Save AnthonyMikh/b2c2647c8358e38626679610a5ff8770 to your computer and use it in GitHub Desktop.
Решение задачи №63 от UniLecs (на этот раз верное)
import qualified Data.Vector.Unboxed as V
--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 multiple
lcm' x y =
let prod = x*y
in prod `seq` prod `div` gcd' x y
lcmOfArr = V.foldl' lcm' 1
main = putStrLn . show . lcmOfArr . V.fromList $ [6 :: Int, 4] --12
@AnthonyMikh
Copy link
Author

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