--get perfect numbers less than n main = print $ perfects 1000 sum_of_factors n = sum [x | x <- [1..n], n `mod` x == 0, x /= n] perfects n = [x | x <- [1..n], sum_of_factors x == x]