(defun is-mersenne-prime (p) (let ((mp (1- (expt 2 p)))) (loop for i from 2 to (isqrt mp) never (zerop (mod mp i))))) (defun generate-perfect-numbers (limit) (let ((perfect-numbers '())) (loop for p from 2 do (when (is-mersenne-prime p) (let ((perfect-num (* (1- (expt 2 p)) (expt 2 (1- p))))) (when (> limit perfect-num) (push perfect-num perfect-numbers) (format t "Generated perfect number: ~A~%" perfect-num))))) perfect-numbers)) (defun main () (let ((limit (read))) (if (some (lambda (x) (= x limit)) (generate-perfect-numbers limit)) (format t "Yes~%") (format t "No~%")))) (main)