Skip to content

Instantly share code, notes, and snippets.

@ahammel
Last active August 29, 2015 14:10
Show Gist options
  • Select an option

  • Save ahammel/58cdfd0fe57cc35e71f1 to your computer and use it in GitHub Desktop.

Select an option

Save ahammel/58cdfd0fe57cc35e71f1 to your computer and use it in GitHub Desktop.
(defn divisible-by? [x y]
(zero? (mod x y)))
(defn relative-prime? [coll x]
(not-any? (partial divisible-by? x)
(take-while (partial not= x) coll)))
(defn generate-primes [n]
(let [src (range 3 n 2)
prime? (partial relative-prime? src)]
(cons 2 (filter prime? src))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment