Largest proper divisor of n: Difference between revisions
Content deleted Content added
Line 288: | Line 288: | ||
maxProperDivisors :: Int -> Int |
maxProperDivisors :: Int -> Int |
||
maxProperDivisors n |
maxProperDivisors n |
||
| |
| null xs = 1 |
||
| otherwise = |
| otherwise = quot n (head xs) |
||
where |
where |
||
root = (floor . sqrt) (fromIntegral n :: Double) |
root = (floor . sqrt) (fromIntegral n :: Double) |
||
xs = take 1 [x | x <- [2 .. root], 0 == rem n x] |
|||
main :: IO () |
main :: IO () |