1
0
Fork 0

Problem 69

This commit is contained in:
Jonathan Chan 2017-07-02 22:57:36 -07:00
parent c69bcaba49
commit 868573fe49
1 changed files with 11 additions and 0 deletions

11
69.hs Normal file
View File

@ -0,0 +1,11 @@
import Math.NumberTheory.Primes.Factorisation
import Data.List
ratio :: Integer -> Double
ratio n = foldr (\(prime, _) acc -> let p = fromIntegral prime in p / (p - 1) * acc) 1.0 $ factorise n
answer :: Integer -> (Integer, Double)
answer n = let range = [2, 4..n]
in maximumBy (\(i1, r1) (i2, r2) -> compare r1 r2) $ zip range $ map ratio range
main = print $ answer 1000000