Problem 1

When I looked to the project_euler website, I was very excited with the problems, so I decided to join and try to solve as much as I can. Since I enjoy Haskell very much, I decided to try to solve them all with it. The first problem is an easy one, in my opinion. Here you can see the problem description. Since Haskell has a powerful list type, I took advantage of that and here it is my one-line solution for this problem:

    f = foldr (+) 0 [a | a <- [1..1000],
            mod a 3 == 0 || mod a 5 == 0]

Published: October 31 2009

blog comments powered by Disqus