euler/Problem12.hs

9 lines
382 B
Haskell

-- The sequence of triangle numbers is generated by adding the natural numbers.
-- So the 7th triangle number would be 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28. ...
-- What is the value of the first triangle number to have over five hundred divisors?
import Data.List
import Euler
triangles = scanl1 (+) [1..] :: [Int]
main = print $ head $ [ n | n <- triangles, length (divisors n) > 500 ]