Run Code  | API  | Code Wall  | Misc  | Feedback  | Login  | Theme  | Privacy  | Patreon 

Perfect numbers

--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]
 run  | edit  | history  | help 0