(defun pCount (number) (let (ans 0) (do ((iterator 1 (+ iterator 2))) ((equal iterator number)) (if (equal (0) (rem iterator 3))) (+ ans iterator) (if (equal (0) (rem iterator 5))) (+ ans iterator) (+ ans 0))))
The object is to find the sum of all numbers divisible by 3 or 5 that are less than or equal to the number fed to the function.
(Problem from the site www.projecteuler.net)
As someone who is still new to the Lisp compiler error messages,
"While compiling pCount : 0 is not a symbol."
this looks like "equal" doesn't like the fact that I'm testing whether something is equal to a lone number, 0 in this case.
Is this the right analysis? And if so, why can I not put a number there?
Is there anything else terribly wrong with the code above?