Created
August 2, 2010 00:25
-
-
Save jsoffer/503939 to your computer and use it in GitHub Desktop.
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
| import Data.Numbers.Primes(primes) | |
| import Data.List(sort, sortBy) | |
| rad :: Integer -> Integer | |
| rad n = product $ f n primes where | |
| f :: Integer -> [Integer] -> [Integer] | |
| f 1 _ = [] | |
| f x (y:ys) = if mod x y == 0 | |
| then y : f (remove y x) ys | |
| else f x ys | |
| remove factor num = if mod num factor == 0 | |
| then remove factor (quot num factor) | |
| else num | |
| lista = map (\k -> (k,rad k)) [1..100000] | |
| ordena :: (Ord a, Ord b) => [(a,b)] -> [(a,b)] | |
| ordena = sortBy (\ a b -> compare (snd a) (snd b)) | |
| main = putStrLn $ show $ (ordena $ sort lista) !! 9999 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment