Created
January 17, 2012 07:07
-
-
Save harvimt/1625368 to your computer and use it in GitHub Desktop.
Euler Problem 69
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
phi :: Int -> Int | |
phi n = length [ k | k <- [1..n], (gcd n k) == 1 ] | |
-- problem69_h :: Int -> Float -> Int -> Int | |
problem69_h cur_n max_phi max_n | |
| cur_n < 0 = max_n | |
| otherwise = | |
let cur_phi = (fromIntegral cur_n) / ( fromIntegral $ phi cur_n) in | |
if cur_phi > max_phi | |
then problem69_h (cur_n - 1) cur_phi cur_n | |
else problem69_h (cur_n - 1) max_phi max_n | |
problem69 = problem69_h 1000000 0 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment