<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Primes</title>
	<atom:link href="http://clj-me.cgrand.net/2008/06/07/primes/feed/" rel="self" type="application/rss+xml" />
	<link>http://clj-me.cgrand.net/2008/06/07/primes/</link>
	<description>When the pupil is ready to learn, a teacher will appear.</description>
	<lastBuildDate>Tue, 07 Sep 2010 05:36:26 +0200</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Cale Gibbard</title>
		<link>http://clj-me.cgrand.net/2008/06/07/primes/comment-page-1/#comment-5</link>
		<dc:creator>Cale Gibbard</dc:creator>
		<pubDate>Sun, 08 Jun 2008 19:41:00 +0000</pubDate>
		<guid isPermaLink="false">http://clj-me.cgrand.net/2008/06/07/primes/#comment-5</guid>
		<description>Just thought I&#039;d point out that 1 is by definition not a prime, since it has a multiplicative inverse (namely itself).&lt;br/&gt;&lt;br/&gt;The following small tweak to the code avoids this:&lt;br/&gt;&lt;br/&gt;(def primes (lazy-cat [2] ((fn this[n]&lt;br/&gt;  (let [potential-divisors (take-while #(&lt;= (* % %) n) primes)]&lt;br/&gt;    (if (some #(zero? (rem n %)) (rest potential-divisors)) &lt;br/&gt;      (recur (+ n 2))&lt;br/&gt;      (lazy-cons n (this (+ n 2)))))) 3)))</description>
		<content:encoded><![CDATA[<p>Just thought I&#8217;d point out that 1 is by definition not a prime, since it has a multiplicative inverse (namely itself).</p>
<p>The following small tweak to the code avoids this:</p>
<p>(def primes (lazy-cat [2] ((fn this[n]<br />  (let [potential-divisors (take-while #(< = (* % %) n) primes)]<br/>    (if (some #(zero? (rem n %)) (rest potential-divisors)) <br />      (recur (+ n 2))<br />      (lazy-cons n (this (+ n 2)))))) 3)))</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Christophe Grand</title>
		<link>http://clj-me.cgrand.net/2008/06/07/primes/comment-page-1/#comment-4</link>
		<dc:creator>Christophe Grand</dc:creator>
		<pubDate>Sun, 08 Jun 2008 08:20:00 +0000</pubDate>
		<guid isPermaLink="false">http://clj-me.cgrand.net/2008/06/07/primes/#comment-4</guid>
		<description>@squeegee: thanks for the link to this interesting paper.</description>
		<content:encoded><![CDATA[<p>@squeegee: thanks for the link to this interesting paper.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: squeegee</title>
		<link>http://clj-me.cgrand.net/2008/06/07/primes/comment-page-1/#comment-3</link>
		<dc:creator>squeegee</dc:creator>
		<pubDate>Sun, 08 Jun 2008 00:19:00 +0000</pubDate>
		<guid isPermaLink="false">http://clj-me.cgrand.net/2008/06/07/primes/#comment-3</guid>
		<description>Very cool.  I found some more discussion in a paper: &lt;a HREF=&quot;http://www.cs.hmc.edu/~oneill/papers/Sieve-JFP.pdf&quot; REL=&quot;nofollow&quot;&gt;The Genuine Sieve of Eratosthenes (pdf)&lt;/a&gt;.  I&#039;ve put up an implementation in clojure-contrib in the file &lt;a HREF=&quot;http://clojure-contrib.svn.sourceforge.net/viewvc/clojure-contrib/trunk/lazy-seqs.clj?view=markup&quot; REL=&quot;nofollow&quot;&gt;lazy-seqs.clj&lt;/a&gt; that borrows ideas from your blog post and the paper (and gives references to them).  Performance averaged over the first 100,000 primes is about 206 microseconds per prime on a 2.16 GHz Core Duo.</description>
		<content:encoded><![CDATA[<p>Very cool.  I found some more discussion in a paper: <a HREF="http://www.cs.hmc.edu/~oneill/papers/Sieve-JFP.pdf" REL="nofollow">The Genuine Sieve of Eratosthenes (pdf)</a>.  I&#8217;ve put up an implementation in clojure-contrib in the file <a HREF="http://clojure-contrib.svn.sourceforge.net/viewvc/clojure-contrib/trunk/lazy-seqs.clj?view=markup" REL="nofollow">lazy-seqs.clj</a> that borrows ideas from your blog post and the paper (and gives references to them).  Performance averaged over the first 100,000 primes is about 206 microseconds per prime on a 2.16 GHz Core Duo.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
