Created
October 21, 2025 17:45
-
-
Save thr0wn/8de684dd9550299e640aec525b8b0f1e to your computer and use it in GitHub Desktop.
Check if a number is prime or not using elist (emacs lisp)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defun is-prime(a) | |
| "Check if a is prime." | |
| (setq b 1) ;; denominator | |
| (setq c nil) ;; 'prime | 'not-prime | nil | |
| (while (null c) | |
| (setq b (+ b 1)) | |
| (setq c (or (if (<= a b) 'prime) (if (eq (% a b) 0) 'not-prime)))) | |
| c | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment