Hi, Charles and all.
Here is my definition of prime numbers:
https://gist.github.com/kohyama/8e599b2e765ad4256f32
HTH.
Yoshinori Kohyama
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
N
Why not turn this problem on its head? Have a vector of lists of prime
factors for each i. March through this vector and for each prime factor in
the current list, add that prime factor p to list i + p. And if i has no
prime factors, then it is a prime itself and add it to the list at 2 * i.
So
Primes are hard, because you essentially need to track all previous primes.
Here's one way to think about what you're doing here. First, you
create a lazy sequence of infinite numbers from 3 and up. This is done
by building a cons cell with 3 as the head and (iterate inc 4) as the
tail.
Then you
This might help:
http://stuartsierra.com/2015/08/25/clojure-donts-lazy-effects
On 24 Sep 2015 01:14, "Charles Reese" wrote:
> I want to compute a lazy sequence of primes.
>
> Here is the interface:
>
> user=> (take 10 primes)
> (2 3 5 7 11 13 17 19 23 29)
>
> So far, so good.
>
> However,
I want to compute a lazy sequence of primes.
Here is the interface:
user=> (take 10 primes)
(2 3 5 7 11 13 17 19 23 29)
So far, so good.
However, when I take 500 primes, this results in a stack overflow.
core.clj: 133 clojure.core/seq
core.