Anonymous user
Fraction reduction: Difference between revisions
m
→{{header|Haskell}}
Line 1,377:
, d <- validIntegers xs
, n < d
, gcd n d /= 1 ]
commonDigits :: Fraction -> [Int]
Line 1,393 ⟶ 1,392:
findReduction :: Fraction -> [Reduction]
findReduction z@(n1, d1) =
where
decimal = realToFrac n1 / realToFrac d1
▲ | decimalWithDrop == decimal = (z, (n2, d2), x) : go xs
▲ | otherwise = go xs
where
n2 = dropDigit x n1
Line 1,423 ⟶ 1,420:
mapM_ (uncurry displayCount) $ zip groups [2..]
where
groups = [ findReductions [10^1..99], findReductions [10^2..999]
, findReductions [10^
{{out}}
<pre>16/64 = 1/4 by dropping 6
|