1
0
Fork 0

Problem 71

This commit is contained in:
Jonathan Chan 2017-07-03 08:54:52 -07:00
parent e815bd6ceb
commit 33a0bdc69f
4 changed files with 9 additions and 0 deletions

BIN
71 Executable file

Binary file not shown.

BIN
71.hi Normal file

Binary file not shown.

9
71.hs Normal file
View File

@ -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

BIN
71.o Normal file

Binary file not shown.