Skip to content

Instantly share code, notes, and snippets.

@abresas
Created April 5, 2019 09:28
Show Gist options
  • Save abresas/3e37d2bd5386bb7595718e0d907fe89b to your computer and use it in GitHub Desktop.
Save abresas/3e37d2bd5386bb7595718e0d907fe89b to your computer and use it in GitHub Desktop.
Solution to project euler problem 21 in haskell
module Amicable where
d :: Int -> Int
d x = sum [n | n <- [1 .. (x `div` 2)], x `mod` n == 0]
amicable :: Int -> Bool
amicable a = d a /= a && (d . d) a == a
main = print $ sum $ filter amicable [1 .. 9999]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment