(defun erath (n) (let ((a (make-array n)) (res nil)) (loop with i = 2 while (< i n) do (if (null (aref a i)) (let () (setf res (cons i res)) (loop for j from i to (1- n) by i do (setf (aref a j) t)))) (setf i (1+ i))) (reverse res))) (defun mupol (l k) (loop for x in l sum (expt x k))) (defun prime-list (k acc nrem pl) (cond ((= 0 nrem) (if (check-ok k acc) (progn (format t "~S ~%" acc) (throw 'list-found acc)))) (t (loop with pl-akt = pl while (not (null pl-akt)) do (prime-list k (cons (car pl-akt) acc) (1- nrem) (cdr pl-akt)) (setf pl-akt (cdr pl-akt)))))) (defun check-ok (k acc) (let ((res (loop with res = nil for l from 1 to k do (setf res (adjoin (mupol acc l) res)) finally return res))) (format t "~S ~%" res) (= k (length res)))) (defun get-primes (k) (catch 'list-found (prime-list k nil k (erath 100))))