Skip to content

Instantly share code, notes, and snippets.

@vijaykiran
Created December 1, 2015 22:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vijaykiran/de72afedc6133805eecc to your computer and use it in GitHub Desktop.
Save vijaykiran/de72afedc6133805eecc to your computer and use it in GitHub Desktop.
divides m n = n `rem` m == 0
divisors :: Int -> [Int]
divisors n = [k | k <- [1..n], k `divides` n]
sigma = sum . divisors
output :: Int -> String
output n
| sigma n > 2 * n = show n ++ " abundant "++ show (sigma n - 2 * n)
| sigma n < 2 * n = show n ++ " deficient "
| otherwise = show n ++ "~~ neither ~~"
list = [111, 112, 220, 69,134,85]
stuff = mapM_ (putStrLn . output) list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment