(defun is-perfect-number (n) (if (< n 2) nil (let ((sum 1) (sqrt-n (isqrt n))) (loop for i from 2 to sqrt-n do (when (zerop (mod n i)) (incf sum i) (let ((other (/ n i))) (unless (= i other) (incf sum other))))) (= sum n)))) (defun main () (let ((n (read))) (if (is-perfect-number n) (format t "Yes~%") (format t "No~%")))) (main)