I'm trying the project euler problems to learn common lisp and I'm stuck pretty early. On problem 1, the question is the sum of integers from 1 to 1000. I think the code below should do it, but it always returns the value of end (if it's mod 3 or mod 5) or 0 instead.
(defun mod3or5 (n)
(cond
((equal (mod n 5) 0) n)
((equal (mod n 3) 0) n)
(0))))
(defun mod-sum (start end)
(cond
((equal start end) (mod3or5 start))
(+ (mod3or5 start) (mod-sum (+ start 1) end))))
For example
(mod-sum 1 9)
=> 9
(mod-sum 1 8)
=> 0
I would expect the answers to be 23 and 14 respectively.