- Code: Select all
`(defun factor-loop (num)`

(let ((factors = '(1)) (remainder = nil) (current-num = (/ num (apply #'* factors))))

(loop do (loop with x = 0

while (or (= (rem num x) 0) (<= x (/ num 2)) (current-num = (/ num (apply #'* factors))))

finally ((setf remainder (rem num x))(return)))

appending factors remainder))

return factors)

This is the error I'm getting, but it's too vague for me to understand exactly what's wrong:

- Code: Select all
`*** - LOOP: illegal syntax near REMAINDER in`

(LOOP WITH FACTORS = '(1) AND CURRENT-NUM = (/ NUM (APPLY #'* FACTORS))

AND REMAINDER = NIL DO

(LOOP WITH X = 0 WHILE (OR (= (REM NUM X) 0) (<= X (/ NUM 2))) FINALLY

((SETF REMAINDER (REM NUM X)) (RETURN)))

APPEND FACTORS REMAINDER)

Again, I'm still quite new to lisp, so the answer is probably glaringly obvious.