Created
April 5, 2019 09:28
-
-
Save abresas/3e37d2bd5386bb7595718e0d907fe89b to your computer and use it in GitHub Desktop.
Solution to project euler problem 21 in haskell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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