Skip to content

Commit

Permalink
euler solution
Browse files Browse the repository at this point in the history
  • Loading branch information
yihuang committed Nov 18, 2011
1 parent d345232 commit 52d6045
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions euler12.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
tris :: [Int]
tris = 1 : 3 : zipWith (\a b -> b + b - a + 1) tris (tail tris)

divisors :: Int -> Int
divisors n = (*) 2 $ (+) 1 $ length . filter (\x -> n `rem` x == 0) $ [2 .. (floor . sqrt . fromIntegral $ n)]

main = print $ head . filter ((>500) . divisors) $ tris

0 comments on commit 52d6045

Please sign in to comment.