Skip to content

Commit

Permalink
add .gitignore
Browse files Browse the repository at this point in the history
fix problem12.hs: use scanl1 instead of mapAccumL
  • Loading branch information
eagletmt committed May 27, 2009
1 parent 01f451a commit 6dc9089
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
@@ -0,0 +1,3 @@
*.hi
*.o
a.out
2 changes: 1 addition & 1 deletion 10-19/problem12.hs
Expand Up @@ -5,7 +5,7 @@ divisors :: (Integral a) => a -> [a]
divisors n = concat [x | i <- [1..floor (sqrt (fromIntegral n))], let (q,r) = n `divMod` i, r == 0, let x = if i == q then [i] else [i,q]]

triangles :: (Integral a) => [a]
triangles = snd $ mapAccumL (\a x -> (a+x, a)) 1 [2..]
triangles = scanl1 (+) [1..]

main = print $ fromJust $ find (\i -> length (divisors i) > 500) $ triangles

0 comments on commit 6dc9089

Please sign in to comment.