Skip to content

Instantly share code, notes, and snippets.

@douglas-vaz
Last active August 29, 2015 14:25
Show Gist options
  • Save douglas-vaz/75398140852062ef09f5 to your computer and use it in GitHub Desktop.
Save douglas-vaz/75398140852062ef09f5 to your computer and use it in GitHub Desktop.
Prime function in Clojure
(defn divisible? [x y] (zero? (mod x y)))
(defn prime? [num]
(or (= num 2) (and (not (even? num)) (not-any? #(divisible? num %) (range 3 (inc (Math/sqrt num)) 2)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment