# Project Euler

posted on 2009-03-21 04:36:00

Today is a marvelous day, because today I found out about Project Euler, which means I'll never want for programming tasks again. Sometimes I really think that all it takes is for someone to decide what (possibly) pointless task you should do, and then you can do it, as opposed to deciding to do it on your own, in which case, you are crazy. In any event, here is my first solution (working with Lisp):

;; Sum all of the multiples of 3 or 5 less than 1000

(loop for i from 1 to 999 when (or (= (mod i 5) 0) (= (mod i 3) 0))

sum i)

For the answer - you'll just have to run it yourself. This taught me a fair bit about Lisp loop forms. They are quite extensive and somewhat confusing. Just when you get used to putting everything into parenthesis, they decid you should actually be typing sentences.

Indeed, it seems like you barely need to write anything except the `loop` statement. This may just be me not quite getting function programming yet. For example, my solution to problem 2:

(defun fibonacci (n)

(if (<>This is quite clunky, I think. We have to calculate the result of the fibonacci function many times (there are, apparently, around 180 even fibonacci numbers smaller than 4000000). I'm still not sure how to do this better, but, I fully intend to consider finding out.