I have a bit of code:
(defun divisor (x)
(loop for i from 2 to x do
(if (= x i) (return x)
(if (not (mod x i))
(return (append i (divisor (/ x i))))))))
that should return a list of the prime factors of x. However, the code just returns x.
The defun evaluates with no errors. I've attempted to trace every function in the defun, and none is ever evaluated. Loop is a macro, so I can't trace it, but if I clear out the inside of the loop and replace with
(format t "~d " i)
it counts from 2 to x, like I would expect.
I assume I've done something wrong, but I can't figure it out.