Skip to content

Instantly share code, notes, and snippets.

@jcromartie
Created November 5, 2009 15:28
Show Gist options
  • Save jcromartie/227123 to your computer and use it in GitHub Desktop.
Save jcromartie/227123 to your computer and use it in GitHub Desktop.
cheating at prime numbers
; creating a seq of prime numbers should *NOT* be this easy!
; this has been around since Java 5, apparently
(defn prime-seq
"Returns a lazy seq of primes (optionally starting from n)"
([] (prime-seq 0))
([n] (let [next-prime #(.nextProbablePrime %)]
(iterate next-prime (next-prime (bigint n))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment