Skip to content

Instantly share code, notes, and snippets.

@ConnorBaker
Last active February 23, 2019 00:51
Show Gist options
  • Select an option

  • Save ConnorBaker/3752010b838f71f9d3a5e2368b355fad to your computer and use it in GitHub Desktop.

Select an option

Save ConnorBaker/3752010b838f71f9d3a5e2368b355fad to your computer and use it in GitHub Desktop.
Programming in Haskell, 2nd ed.: Chapter 5: Problem 6
factors :: Int -> [Int]
factors n = [x | x <- [1..n], n `mod` x == 0]
perfects :: Int -> [Int]
perfects n = [x | x <- [1..n],
x == sum (factors x) - ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment