module Exercise_6 where import Data.Ratio import Data.List (find) import Data.Ratio (Ratio, (%), denominator) {-WETT-} traceFractran :: [Rational] -> Integer -> [Integer] traceFractran fracts n = n : case find (\f -> n `mod` denominator f == 0) fracts of Nothing -> [] Just f -> traceFractran fracts $ truncate (fromIntegral n * f) {-TTEW-}