This program will hopefully generate prime numbers.
Define a function that tests if a number wholly divides another number.
(defun pr/whole-remainder (x y)
"This will tell you if y evenly divides x"
(if (eq 0 (% x y))
t nil))
pr/whole-remainder
This function recursively tests if a number is prime.
(defun pr/is-prime (x y)
"return t if x is prime"
(cond
;; if y == 1, then x is prime
((when (eq y 1)
t))
;; make sure that y <= (/ x 2)
((when (> y
(/ x 2))
(pr/is-prime x (+ 1 (/ y 2)))))
;; if y evenly divides x, then x is NOT prime
((eq t (pr/whole-remainder x y))
nil)
;; if y does not evenly divide x, then does y-1 divide x?
((pr/is-prime x (- y 1)))))
pr/is-prime
(provide 'prime-number-generator)