Created
January 22, 2018 19:50
-
-
Save AnthonyMikh/b2c2647c8358e38626679610a5ff8770 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
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Playground: https://paiza.io/projects/cZiHtM6g4s5uHpYm73cKVQ?language=haskell