2024-03-04 05:16:06 +00:00
|
|
|
(defmacro with-gensyms ((&rest names) &body body)
|
|
|
|
"Creates variables named NAMES via GENSYM and runs BODY"
|
|
|
|
`(let ,(loop for name in names collect `(,name (gensym)))
|
|
|
|
,@body))
|
|
|
|
|
2024-02-29 18:29:58 +00:00
|
|
|
(defun get-primes (max)
|
|
|
|
(let ((primes nil)
|
|
|
|
(composites (make-array (1+ max) :initial-element 0)))
|
|
|
|
(loop for n from 2 upto max
|
|
|
|
do (when (= 0 (aref composites n))
|
|
|
|
(push n primes)
|
|
|
|
(loop for m from (* 2 n) upto max by n
|
|
|
|
do (incf (aref composites m)))))
|
|
|
|
(nreverse primes)))
|