Jump to content

Fraction reduction: Difference between revisions

m
(added Haskell)
Line 1,414:
 
countReductions :: [(Fraction, Fraction, Int)] -> [(Int, Int)]
countReductions = fmap (\ys(,) ->. (length ys,<*> head ys)) . group . sort . fmap (\(_, _, x) -> x)
 
displayCount :: [(Fraction, Fraction, Int)] -> Int -> IO ()
Line 1,484:
17 have 8's omitted
390 have 9's omitted</pre>
 
=={{header|J}}==
The algorithm generates all potential rational fractions of given size in base 10 and successively applies conditions to restrict the candidates. By avoiding boxing and rational numbers this version is much quicker than that which may be found in the page history.
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.