Created
November 5, 2009 15:28
-
-
Save jcromartie/227123 to your computer and use it in GitHub Desktop.
cheating at prime numbers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; 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