Haskell Chocolates By Numbers
chocolatesByNumbers :: Int -> Int -> Int
chocolatesByNumbers n m = (n * m) `div` gcd n m `div` m
This uses the greatest common divisor to figure out how many chocolates get eaten before the pattern repeats.
chocolatesByNumbers :: Int -> Int -> Int
chocolatesByNumbers n m = (n * m) `div` gcd n m `div` m
This uses the greatest common divisor to figure out how many chocolates get eaten before the pattern repeats.