<?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: The Sieve of Atkin in C#</title>
	<atom:link href="http://www.geekality.net/2009/10/19/the-sieve-of-atkin-in-c/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.geekality.net/2009/10/19/the-sieve-of-atkin-in-c/</link>
	<description>With a hint of Social Ineptitude</description>
	<lastBuildDate>Tue, 07 Feb 2012 09:05:01 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: To find the list of primes till N. &#124; I Live to Seek&#8230;</title>
		<link>http://www.geekality.net/2009/10/19/the-sieve-of-atkin-in-c/#comment-9943</link>
		<dc:creator>To find the list of primes till N. &#124; I Live to Seek&#8230;</dc:creator>
		<pubDate>Wed, 26 Oct 2011 02:36:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.geekality.net/?p=674#comment-9943</guid>
		<description>[...] Wikipedia Implementation C#  [...]</description>
		<content:encoded><![CDATA[<p>[...] Wikipedia Implementation C#  [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben</title>
		<link>http://www.geekality.net/2009/10/19/the-sieve-of-atkin-in-c/#comment-6260</link>
		<dc:creator>Ben</dc:creator>
		<pubDate>Wed, 22 Jun 2011 13:37:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.geekality.net/?p=674#comment-6260</guid>
		<description>The list of primes takes more memory stored as a list than as the bool array it&#039;s calculated in.

It also requires memory for both to change from one to the other.

I replaced primes with the isPrime array (moved to class-level), changed the IEnumerator to this:

&lt;code&gt;
public IEnumerator&lt;ulong&gt; GetEnumerator() {
            if (!primeFlag) {
                FindPrimes();
                isPrime[2] = true;
                isPrime[3] = true;
                primeFlag = true;
            }
            for (ulong i = 2;i&lt;limit;i++) {
                if (isPrime[i]){
                    yield return i;
                }
            }
        }
&lt;/code&gt;

If memory still remains a problem, there are a number of memory optimisations that can be made, some at the expense of performance (for example, only representing odd numbers in isPrime).</description>
		<content:encoded><![CDATA[<p>The list of primes takes more memory stored as a list than as the bool array it&#8217;s calculated in.</p>
<p>It also requires memory for both to change from one to the other.</p>
<p>I replaced primes with the isPrime array (moved to class-level), changed the IEnumerator to this:</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">public IEnumerator&lt;ulong&gt; GetEnumerator() {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (!primeFlag) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FindPrimes();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; isPrime[2] = true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; isPrime[3] = true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; primeFlag = true;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for (ulong i = 2;i&lt;limit;i++) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (isPrime[i]){<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; yield return i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; }</div></div>
<p>If memory still remains a problem, there are a number of memory optimisations that can be made, some at the expense of performance (for example, only representing odd numbers in isPrime).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Torleif</title>
		<link>http://www.geekality.net/2009/10/19/the-sieve-of-atkin-in-c/#comment-2647</link>
		<dc:creator>Torleif</dc:creator>
		<pubDate>Fri, 03 Dec 2010 20:01:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.geekality.net/?p=674#comment-2647</guid>
		<description>Like I said, I am not going to try to explain why the algorithm works. But it does, and there are tests in my code that proves it. Just try it out for yourself :)

You can read about the algorithm &lt;a href=&quot;http://en.wikipedia.org/wiki/Sieve_of_Atkin#Algorithm&quot; rel=&quot;nofollow&quot;&gt;at wikipedia&lt;/a&gt;,</description>
		<content:encoded><![CDATA[<p>Like I said, I am not going to try to explain why the algorithm works. But it does, and there are tests in my code that proves it. Just try it out for yourself <img src='http://www.geekality.net/wp-includes/images/blank.gif' alt=':)' class='wp-smiley smiley-1' /> </p>
<p>You can read about the algorithm <a href="http://en.wikipedia.org/wiki/Sieve_of_Atkin#Algorithm" rel="nofollow">at wikipedia</a>,</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ajay</title>
		<link>http://www.geekality.net/2009/10/19/the-sieve-of-atkin-in-c/#comment-2638</link>
		<dc:creator>Ajay</dc:creator>
		<pubDate>Fri, 03 Dec 2010 15:38:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.geekality.net/?p=674#comment-2638</guid>
		<description>I still dnt understand. how could this code works??
i mean take an example of nubmer 65..

4*2*2 + 7*7 =65..... markdes as true in first loop....
after then.... it would never be unmarked and would be in output inspite of being a composite....


admin plzz solve this issue,,,,</description>
		<content:encoded><![CDATA[<p>I still dnt understand. how could this code works??<br />
i mean take an example of nubmer 65..</p>
<p>4*2*2 + 7*7 =65&#8230;.. markdes as true in first loop&#8230;.<br />
after then&#8230;. it would never be unmarked and would be in output inspite of being a composite&#8230;.</p>
<p>admin plzz solve this issue,,,,</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: yofreke</title>
		<link>http://www.geekality.net/2009/10/19/the-sieve-of-atkin-in-c/#comment-1689</link>
		<dc:creator>yofreke</dc:creator>
		<pubDate>Tue, 26 Oct 2010 06:16:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.geekality.net/?p=674#comment-1689</guid>
		<description>(my code uses longs)
long xy =  x * x + y * y;
var n = 4 * xy;
...
n = 3 * xy;
I tried this and it took about 1/3 less of the time with my setup.</description>
		<content:encoded><![CDATA[<p>(my code uses longs)<br />
long xy =  x * x + y * y;<br />
var n = 4 * xy;<br />
&#8230;<br />
n = 3 * xy;<br />
I tried this and it took about 1/3 less of the time with my setup.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Torleif</title>
		<link>http://www.geekality.net/2009/10/19/the-sieve-of-atkin-in-c/#comment-1581</link>
		<dc:creator>Torleif</dc:creator>
		<pubDate>Wed, 20 Oct 2010 00:44:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.geekality.net/?p=674#comment-1581</guid>
		<description>Well, I suppose, but I have a feeling that allocating the variables might be slower than just doing the calculation... have you tried it out?</description>
		<content:encoded><![CDATA[<p>Well, I suppose, but I have a feeling that allocating the variables might be slower than just doing the calculation&#8230; have you tried it out?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Torleif</title>
		<link>http://www.geekality.net/2009/10/19/the-sieve-of-atkin-in-c/#comment-1579</link>
		<dc:creator>Torleif</dc:creator>
		<pubDate>Tue, 19 Oct 2010 22:02:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.geekality.net/?p=674#comment-1579</guid>
		<description>Ooh, good catch. Hadn&#039;t tried it with that large values. Seems like it will fail for two reasons. First of all, the array can only contain &lt;code inline=&quot;true&quot;&gt;int32.MaxValue&lt;/code&gt; items. Secondly, you&#039;ll run out of memory :P

Do you have any suggestions on how to fix it? I have a feeling this more a flaw of the algorithm itself than my implementation though... but yeah, if you have any smart solutions please let me know!</description>
		<content:encoded><![CDATA[<p>Ooh, good catch. Hadn&#8217;t tried it with that large values. Seems like it will fail for two reasons. First of all, the array can only contain <code class="codecolorer text default"><span class="text">int32.MaxValue</span></code> items. Secondly, you&#8217;ll run out of memory <img src='http://www.geekality.net/wp-includes/images/blank.gif' alt=':P' class='wp-smiley smiley-13' /> </p>
<p>Do you have any suggestions on how to fix it? I have a feeling this more a flaw of the algorithm itself than my implementation though&#8230; but yeah, if you have any smart solutions please let me know!</p>
]]></content:encoded>
	</item>
</channel>
</rss>

