Skip to content

Instantly share code, notes, and snippets.

@thr0wn
Created October 21, 2025 17:45
Show Gist options
  • Select an option

  • Save thr0wn/8de684dd9550299e640aec525b8b0f1e to your computer and use it in GitHub Desktop.

Select an option

Save thr0wn/8de684dd9550299e640aec525b8b0f1e to your computer and use it in GitHub Desktop.
Check if a number is prime or not using elist (emacs lisp)
(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