2 ms·
That's a school exercise, but I can't resist adding a haskell version - perfects = [n | n <- [1..], n == sum (divisors n)] where divisors n = [k |
by aufreak3 16y ago
That's a school exercise, but I can't resist adding a haskell version -
perfects = [n | n <- [1..], n == sum (divisors n)]
where
divisors n = [k | k <- [1..(n `div` 2)], n `mod` k == 0]