<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Das Sieb des Eratosthenes]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe versucht &quot;Das Sieb des Eratosthenes&quot; zu implementieren aber ich habe leider dumme Fehler im Programm weil er komischweise die 99 ausgibt die ja aber keine Primzahl ist, hier mein Code:</p>
<pre><code class="language-cpp">const int MAX = 100;
bool  zahlen[MAX] = {false};

for(int i=2;i&lt;MAX;i++)
{
	for(int j=2;j&lt;MAX/i;j++)
	{
		zahlen[i*j] = true;
	}
}

for(int i=2;i&lt;MAX;i++)
	if(!zahlen[i])cout &lt;&lt; &quot;Zahl: &quot; &lt;&lt; i &lt;&lt; &quot;\n&quot;;
</code></pre>
<p>Warum gibt der die 99 aus ??</p>
<p>Gruß,<br />
Sil</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/147806/das-sieb-des-eratosthenes</link><generator>RSS for Node</generator><lastBuildDate>Fri, 04 Sep 2026 10:23:53 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/147806.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 20 May 2006 09:22:30 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Das Sieb des Eratosthenes on Sat, 20 May 2006 09:22:30 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich habe versucht &quot;Das Sieb des Eratosthenes&quot; zu implementieren aber ich habe leider dumme Fehler im Programm weil er komischweise die 99 ausgibt die ja aber keine Primzahl ist, hier mein Code:</p>
<pre><code class="language-cpp">const int MAX = 100;
bool  zahlen[MAX] = {false};

for(int i=2;i&lt;MAX;i++)
{
	for(int j=2;j&lt;MAX/i;j++)
	{
		zahlen[i*j] = true;
	}
}

for(int i=2;i&lt;MAX;i++)
	if(!zahlen[i])cout &lt;&lt; &quot;Zahl: &quot; &lt;&lt; i &lt;&lt; &quot;\n&quot;;
</code></pre>
<p>Warum gibt der die 99 aus ??</p>
<p>Gruß,<br />
Sil</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1061420</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1061420</guid><dc:creator><![CDATA[Sil]]></dc:creator><pubDate>Sat, 20 May 2006 09:22:30 GMT</pubDate></item><item><title><![CDATA[Reply to Das Sieb des Eratosthenes on Sat, 20 May 2006 09:37:35 GMT]]></title><description><![CDATA[<p>Hmm, dein Code sieht eigentlich ganz ok so aus. Mir fällt nur was an der Arraygröße auf. Bei meiner Funktion deklariere ich das Array mit [MAX+1].</p>
<p>Gruß Chris</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1061427</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1061427</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sat, 20 May 2006 09:37:35 GMT</pubDate></item><item><title><![CDATA[Reply to Das Sieb des Eratosthenes on Sat, 20 May 2006 09:39:06 GMT]]></title><description><![CDATA[<p>for(int j=2;j**&lt;=**MAX/i;j++)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1061428</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1061428</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Sat, 20 May 2006 09:39:06 GMT</pubDate></item><item><title><![CDATA[Reply to Das Sieb des Eratosthenes on Sat, 20 May 2006 09:38:44 GMT]]></title><description><![CDATA[<p>MAX/i ist ein integer (es wird abgerundet), Du vergleichst auf &lt;</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1061429</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1061429</guid><dc:creator><![CDATA[SG1]]></dc:creator><pubDate>Sat, 20 May 2006 09:38:44 GMT</pubDate></item><item><title><![CDATA[Reply to Das Sieb des Eratosthenes on Sat, 20 May 2006 09:46:28 GMT]]></title><description><![CDATA[<p>Stimmt, habe ich auch zuerst nich gesehen. Ich prüfe auch in beiden Schleifen auf &lt;=</p>
<pre><code class="language-cpp">for (int i = 2; i &lt;= N/2; i++)
	    for (int j = 2; j &lt;= N/i; j++)
              a[i*j] = 1;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1061439</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1061439</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sat, 20 May 2006 09:46:28 GMT</pubDate></item></channel></rss>