Anonymous user
Fraction reduction: Difference between revisions
m
→{{header|Haskell}}
Line 1,370:
possibleFractions :: [Int] -> [Fraction]
possibleFractions xs = [(n,d) | n <- validIntegers xs
,
, gcd n
digits :: Integral a => a -> a -> [a]
Line 1,382 ⟶ 1,381:
digitsToIntegral = sum . zipWith (*) (iterate (*10) 1)
where
commonDigits (n1, n2) = digits 10 n1 `intersect` digits 10 n2
Line 1,395 ⟶ 1,394:
decimalWithDrop = realToFrac n2 / realToFrac d2
showReduction :: Reduction -> IO ()
Line 1,413 ⟶ 1,412:
mapM_ (uncurry showCount) $ zip groups [2..]
where
groups = [
,
{{out}}
<pre>16/64 = 1/4 by dropping 6
|