Skip to content

Instantly share code, notes, and snippets.

@omasanori
Created September 28, 2011 22:10
Show Gist options
  • Select an option

  • Save omasanori/1249395 to your computer and use it in GitHub Desktop.

Select an option

Save omasanori/1249395 to your computer and use it in GitHub Desktop.
A hobby implementation to calculate prime numbers.
(defn prime?
"Returns true if x is prime number, false otherwise."
[x]
(not-any? zero?
(map #(rem x %)
(range 2 (inc (/ x 2))))))
(defn prime-numbers
"Returns a lazy seq of prime numbers."
[]
(filter prime? (drop 2 (range))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment