module Exercise_6 where import Data.Ratio import Data.Bits traceFractranFast :: [Rational] -> Integer -> [Integer] traceFractranFast rs n = n : case [ numerator $ fromIntegral n * r | r <- rs, n `mod` denominator r == 0 ] of (n:_) -> traceFractranFast rs n ns -> ns {-WETT-} traceFractran :: [Rational] -> Integer -> [Integer] traceFractran rs n = n : concat (take 1 [ traceFractran rs . numerator $ fromIntegral n * r | r <- rs, n `mod` denominator r == 0 ]) {-TTEW-} isPower2 :: (Bits i, Integral i) => i -> Bool isPower2 n = n .&. (n-1) == 0 primeprog = [17%91 ,78%85 ,19%51 ,23%38 ,29%33 ,77%29 ,95%23 ,77%19 ,1%17, 11%13 ,13%11 ,15%14 ,15%2 ,55%1]