Largest proper divisor of n: Difference between revisions

Content added Content deleted
(→‎{{header|Raku}}: demonstrate for some larger numbers too)
Line 290:
| 1 < length ab = quot n (last ab)
| otherwise = 1
where
root = (floor . sqrt) (fromIntegral n :: Double)
ab = take 2 $[x | x <- [1 .. root] >>= (\x -> [x |, 0 == rem n x])
 
main :: IO ()
main =
(putStr . unlines . map concat . chunksOf 10) $
printf "%3d" . maxProperDivisors <$> [1 .. 100]</lang>
 
<pre> 1 1 1 2 1 3 1 4 3 5