Commits

David Jones committed b90930c

added simple prime test.

Comments (0)

Files changed (1)

lisp/basic-math.lisp

   "Calculate (M choose N) * factorial N.  The result is
  (* M (M-1) (M-2) ... (N+1))"
   (if (and (> m 0)
-
            (> n 0)
            (>= m n))
       (let ((numerator 1))
         numerator)))
 
 
+(defun is-prime-dumb (n)
+  "Super simple prime test.  Not meant for real use, but could be used
+to test better prime tester functions."
+  (cond ((<  n 2) nil)
+        ((= 2 n) t)
+        ((= (mod n 2) 0) (values nil 2))
+        (t
+         (do ((i 3 (+ 2 i)))
+             ((>= i (sqrt n)) n)
+           (when (= (mod n i) 0) 
+             (return (values nil i)))))))
+
+