Proper divisors: Difference between revisions
m
→{{header|Haskell}}: (Tidying)
m (→{{header|Ada}}) |
m (→{{header|Haskell}}: (Tidying)) |
||
Line 2,004:
<lang haskell>import Data.List (maximumBy)
import Data.Ord (comparing)
import
properDivisors
Line 2,012:
let root = (floor . sqrt . fromIntegral) n
lows = filter ((0 ==) . rem n) [1 .. root]
in init (lows ++ bool id tail (n == root * root) (reverse (quot n <$> lows)))▼
▲ (reverse (quot n <$> lows)))
main :: IO ()
Line 2,032 ⟶ 2,027:
print $
maximumBy (comparing snd) $
{{Out}}
<pre>Proper divisors of 1 to 10:
|