Largest proper divisor of n: Difference between revisions

→‎{{header|Haskell}}: Applied HLint and Ormolu, tidied.
(Add Cowgol)
(→‎{{header|Haskell}}: Applied HLint and Ormolu, tidied.)
Line 207:
lpd :: Int -> Int
lpd 1 = 1
lpd n = head $ [x | x <- [n -1, n -2 .. 1], n `mod` x == 0]
 
main :: IO ()
main = putStr $
(putStr . unlines . map concat . chunksOf 10) $
map printf "%3d" . lpd <$> [1 .. 100]</lang>
map concat $
chunksOf 10 $
map (printf "%3d") $
map lpd [1..100]</lang>
{{out}}
<pre> 1 1 1 2 1 3 1 4 3 5
9,659

edits