Skip to content

Instantly share code, notes, and snippets.

@jarpiain jarpiain/gist:654521
Created Oct 29, 2010

What would you like to do?
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
You can’t perform that action at this time.