primes/primes.lisp

19 lines
343 B
Common Lisp
Raw Normal View History

2011-03-08 07:01:27 +00:00
; Common Lisp version of a Prime Number Finder
; haplo@mindstab.net
(defun check (max i sq)
(if (> i sq)
(format t "~d~%" max)
(if (not (= (mod max i) 0))
(check max (+ i 2) sq))))
(defun _primes (max i)
(if (< i max)
(progn
(check i 3 (sqrt i))
(_primes max (+ i 2)))))
(defun primes (max)
(_primes max 3))