Lispy code? Prime factors of a number My answer to Project Euler problem 3 (largest prime factor of 600851475143) is below.
Please suggest improvements, style changes, indentation, commenting, naming of &quot;objects&quot;, ...
(defun factors (n)
    &quot;return a list with prime factors of n&quot;
    (let ((result))
        (loop while (zerop (rem n 2))           ; do 2
              do (loop while (zerop (rem n 2))
                       do (setf n (/ n 2))
                       do (setf result (cons 2 result))))
        (loop for i from 3 by 2                 ; do 3, 5, 7, 9, ...
              while (&gt;= n (* i i))              ; until square root of what's left of n
              do (loop while (zerop (rem n i))
                       do (setf n (/ n i))
                       do (setf result (cons i result))))
        (if (= n 1) result (cons n result))))   ; if n is not 1 it is also a factor

Questions:

Is the (let ((result)) #| ... (setf result ...) ... |# result) construction acceptable?
I like the result as it is, in reverse; but, other than (reverse result) is there a way to collect factors into result? My attempts with collect i (or collect i into result) would not compile.
Your code is perfectly fine, except for a few nitpicks.

Use push instead of (setf x (conx y x)) for readability.

Use floor instead of rem + / for efficiency.

1st and 3rd loops are identical, so they should be abstracted into a local flet function.

Use nreverse instead of reverse for the return value.  Yes, you can avoid that by using collect combined with nconc but it makes little sense in your specific case.