Skip to content

Instantly share code, notes, and snippets.

@jneira
Created December 22, 2014 20:17
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 jneira/d280cbdde3a533a715d2 to your computer and use it in GitHub Desktop.
Save jneira/d280cbdde3a533a715d2 to your computer and use it in GitHub Desktop.
a057531=[e | e<-[0..], (sum $ digits e) == (length $ divisors e)]
where divisors n=n:[i|i <- [1..n `div` 2], n `mod` i==0]
digits 0=[]
digits n=mod n 10: digits (div n 10)
*Exercitium> last $ takeWhile (<2015) a057531
2006
*Exercitium> head $ dropWhile (<=2015) a057531
2101
*Exercitium> length $ takeWhile (<=2015) a057531
59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment