Skip to content

Instantly share code, notes, and snippets.

@jarpiain
Created October 29, 2010 21:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jarpiain/654521 to your computer and use it in GitHub Desktop.
Save jarpiain/654521 to your computer and use it in GitHub Desktop.
Primality testing
(defn prime? [n]
(let [n (int n)
q (int (Math/sqrt (double n)))]
(loop [i 2]
(if (> i q) true
(if (zero? (unchecked-remainder n i)) false
(recur (inc i)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment