Largest proper divisor of n: Difference between revisions
Content deleted Content added
Line 283:
(Otherwise, the largest proper divisor will be 1 itself).
<lang haskell>import Data.List
import Data.List.Split (chunksOf)
import Text.Printf (printf)
maxProperDivisors :: Int -> Int
maxProperDivisors n =
case find ((0 ==) . rem n) [2 .. root] of
Nothing -> 1
Just x -> quot n x
where
root = (floor . sqrt) (fromIntegral n :: Double)
main :: IO ()
|