Skip to content

Instantly share code, notes, and snippets.

@haywoood
Created October 15, 2013 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save haywoood/6992375 to your computer and use it in GitHub Desktop.
Save haywoood/6992375 to your computer and use it in GitHub Desktop.
(def primes
(concat
[2 3 5 7] (lazy-seq
(let [primes-from
(fn primes-from [n [f & r]]
(if (some #(zero? (rem n %))
(take-while #(<= (* % %) n) primes))
(recur (+ n f) r)
(lazy-seq (cons n (primes-from (+ n f) r))))) wheel(cycle[24246264246626 4 2 64684242486462 4 6
2 6 6 4 2 4 6 2 6 4 2 4 2 10 2 10])]
(primes-from 11 wheel)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment