lisp codeEn 2016-11-21 14:30:04
Prime number
(defun prime-number-p (number)
  "Returns true if the number is prime; otherwise returns false"
  (let ((counter 2)); the second prime number
      ;; special case
      ;; the definition of prime number
      ((equal number 1)
      ;; apply the  prime number definition
      (when  (equal counter number)
        (return t))
      (if (= (mod number counter) 0)
          (return nil))
      (incf counter))))))

También te puede interesar
lisp codeEn 2022-07-13 13:12:00