Problem 71
This commit is contained in:
parent
e815bd6ceb
commit
33a0bdc69f
|
@ -0,0 +1,9 @@
|
|||
import Data.Ratio
|
||||
|
||||
closer :: Rational -> Rational -> Rational
|
||||
closer curr prev = let goal = (3 % 7) in if curr < goal && (goal - curr) < (goal - prev) then curr else prev
|
||||
|
||||
closest :: Integer -> Rational
|
||||
closest bound = foldr closer 0 $ map (\d -> let n = floor (d * 3 % 7) in (n % d)) [8..bound]
|
||||
|
||||
main = print $ closest 1000000
|
Loading…
Reference in New Issue