<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'prime numbers' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'prime numbers' posted on the 'Algorithms' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Fri, 24 May 2013 23:41:38 -0700</pubDate>
    <lastBuildDate>Fri, 24 May 2013 23:41:38 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>prime numbers</title>
      <link>http://www.programmersheaven.com/mb/Algorithms/253189/253189/prime-numbers/</link>
      <description>please can anyone give me the algorithms for finding prime numbers below a number, given that number.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/Algorithms/253189/253189/prime-numbers/</guid>
      <pubDate>Mon, 05 Apr 2004 19:28:35 -0700</pubDate>
      <category>Algorithms</category>
    </item>
    <item>
      <title>Re: prime numbers</title>
      <link>http://www.programmersheaven.com/mb/Algorithms/253189/256847/re-prime-numbers/#256847</link>
      <description>: please can anyone give me the algorithms for finding prime numbers below a number, given that number.&lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Hint:If a number is not divisible to any of the prime numbers below itself then it is a prime number too.&lt;br /&gt;
&lt;br /&gt;
Create an array to hold the found prime numbers.&lt;br /&gt;
Add the first prime number 2 as the first object of the array.&lt;br /&gt;
Create a variable for current value and initialize it to 3.&lt;br /&gt;
In a loop which repeats the statements until the variable is updated to the given number take the remainder of the current variable/objects of the array(holds found prime numbers), add the current variable to the array if any of the remainders is equal to zero(this means none of the prime numbers divides the current value) and update the current variable by adding one to it.&lt;br /&gt;
After the break of loop you can print out the values in the array and see the prime numbers below the desired number.&lt;br /&gt;
&lt;br /&gt;
I'm a first year computer science student.Sorry if i confused you. This is not an algorithm but i think it can give you a clue about how to solve the problem.&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/Algorithms/253189/256847/re-prime-numbers/#256847</guid>
      <pubDate>Thu, 29 Apr 2004 16:31:12 -0700</pubDate>
      <category>Algorithms</category>
    </item>
    <item>
      <title>Re: prime numbers</title>
      <link>http://www.programmersheaven.com/mb/Algorithms/253189/257670/re-prime-numbers/#257670</link>
      <description>&lt;strong&gt;&lt;span style="color: Red;"&gt;This message was edited by gaetano at  2004-5-5 4:6:11&lt;/span&gt;&lt;/strong&gt;&lt;hr /&gt;&lt;br /&gt;
&lt;span style="color: Grey;"&gt;please can anyone give me the algorithms for finding prime numbers below a number, given that number.&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: Green;"&gt;&lt;br /&gt;
The maybe easiest implementation for an algorithm which finds primes&lt;br /&gt;
in a given range is the so-called "Sieve Of Erathostenes".&lt;br /&gt;
&lt;br /&gt;
The advantages:&lt;br /&gt;
- you will find really every prime&lt;br /&gt;
- every found prime is 100% a prime&lt;br /&gt;
&lt;br /&gt;
The disadvantages:&lt;br /&gt;
- the array takes a lot of memory&lt;br /&gt;
- the computation time is long for high ranges&lt;br /&gt;
&lt;br /&gt;
If you need the "sieve" in another language than C/C++, just use any&lt;br /&gt;
search engine. You'll find everything you need ...&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;&lt;span style="font-size: x-small;"&gt;
#include &amp;lt;iostream&amp;gt;
using namespace std;

int
main (void)
{
	long	max;
	bool	*primes;

	cout &amp;lt;&amp;lt; " Calculate prime numbers (sieve of Erathostenes)\n\n";
	cout &amp;lt;&amp;lt; " Highest number to test: ";
	cin &amp;gt;&amp;gt; max;

	if (max &amp;lt; 2) {
		cerr &amp;lt;&amp;lt; " Error: Invalid value!\n"
		     &amp;lt;&amp;lt; "        Number must be greater than 2.\n";
		return 1;
	}

&lt;span style="color: Blue;"&gt;	// Create array and exclude 0 and 1&lt;/span&gt;
	primes = new bool[max + 1];

&lt;span style="color: Blue;"&gt;	// Fill list with all positive integers&lt;/span&gt;
	for (long i=0; i&amp;lt;=max; i++)
		primes[i] = true;

&lt;span style="color: Blue;"&gt;	// The testing ...&lt;/span&gt;
	for (long i=2; i&amp;lt;=max; i++)
		for (long j=2; i*j&amp;lt;max; j++)
			primes[i*j] = false;

&lt;span style="color: Blue;"&gt;	// The index of the array equals the numbers&lt;/span&gt;
&lt;span style="color: Blue;"&gt;	// If you want to look whether 7 is a prime, just try&lt;/span&gt;
&lt;span style="color: Blue;"&gt;	// if `(primes[7])'&lt;/span&gt;

&lt;span style="color: Blue;"&gt;	// Print them&lt;/span&gt;
	for (long i=2; i&amp;lt;=max; i++)
		if (primes[i])
			cout &amp;lt;&amp;lt; i &amp;lt;&amp;lt; endl;

	delete[] primes;
	return 0;
}
&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/Algorithms/253189/257670/re-prime-numbers/#257670</guid>
      <pubDate>Wed, 05 May 2004 04:05:19 -0700</pubDate>
      <category>Algorithms</category>
    </item>
    <item>
      <title>Re: prime numbers</title>
      <link>http://www.programmersheaven.com/mb/Algorithms/253189/281058/re-prime-numbers/#281058</link>
      <description>: &lt;strong&gt;&lt;span style="color: Red;"&gt;This message was edited by gaetano at  2004-5-5 4:6:11&lt;/span&gt;&lt;/strong&gt;&lt;hr /&gt;&lt;br /&gt;
: &lt;span style="color: Grey;"&gt;please can anyone give me the algorithms for finding prime numbers below a number, given that number.&lt;br /&gt;
: &lt;/span&gt;&lt;br /&gt;
: &lt;br /&gt;
: &lt;span style="color: Green;"&gt;&lt;br /&gt;
: The maybe easiest implementation for an algorithm which finds primes&lt;br /&gt;
: in a given range is the so-called "Sieve Of Erathostenes".&lt;br /&gt;
: &lt;br /&gt;
: The advantages:&lt;br /&gt;
: - you will find really every prime&lt;br /&gt;
: - every found prime is 100% a prime&lt;br /&gt;
: &lt;br /&gt;
: The disadvantages:&lt;br /&gt;
: - the array takes a lot of memory&lt;br /&gt;
: - the computation time is long for high ranges&lt;br /&gt;
: &lt;br /&gt;
: If you need the "sieve" in another language than C/C++, just use any&lt;br /&gt;
: search engine. You'll find everything you need ...&lt;br /&gt;
: &lt;/span&gt;&lt;br /&gt;
: &lt;br /&gt;
: &lt;pre class="sourcecode"&gt;&lt;span style="font-size: x-small;"&gt;
: #include &amp;lt;iostream&amp;gt;
: using namespace std;
: 
: int
: main (void)
: {
: 	long	max;
: 	bool	*primes;
: 
: 	cout &amp;lt;&amp;lt; " Calculate prime numbers (sieve of Erathostenes)\n\n";
: 	cout &amp;lt;&amp;lt; " Highest number to test: ";
: 	cin &amp;gt;&amp;gt; max;
: 
: 	if (max &amp;lt; 2) {
: 		cerr &amp;lt;&amp;lt; " Error: Invalid value!\n"
: 		     &amp;lt;&amp;lt; "        Number must be greater than 2.\n";
: 		return 1;
: 	}
: 
: &lt;span style="color: Blue;"&gt;	// Create array and exclude 0 and 1&lt;/span&gt;
: 	primes = new bool[max + 1];
: 
: &lt;span style="color: Blue;"&gt;	// Fill list with all positive integers&lt;/span&gt;
: 	for (long i=0; i&amp;lt;=max; i++)
: 		primes[i] = true;
: 
: &lt;span style="color: Blue;"&gt;	// The testing ...&lt;/span&gt;
: 	for (long i=2; i&amp;lt;=max; i++)
: 		for (long j=2; i*j&amp;lt;max; j++)
: 			primes[i*j] = false;
: 
: &lt;span style="color: Blue;"&gt;	// The index of the array equals the numbers&lt;/span&gt;
: &lt;span style="color: Blue;"&gt;	// If you want to look whether 7 is a prime, just try&lt;/span&gt;
: &lt;span style="color: Blue;"&gt;	// if `(primes[7])'&lt;/span&gt;
: 
: &lt;span style="color: Blue;"&gt;	// Print them&lt;/span&gt;
: 	for (long i=2; i&amp;lt;=max; i++)
: 		if (primes[i])
: 			cout &amp;lt;&amp;lt; i &amp;lt;&amp;lt; endl;
: 
: 	delete[] primes;
: 	return 0;
: }
: &lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Can you give me some pseudocode to Intel assembly?  thanks didn't find it on google&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/Algorithms/253189/281058/re-prime-numbers/#281058</guid>
      <pubDate>Wed, 10 Nov 2004 21:04:52 -0700</pubDate>
      <category>Algorithms</category>
    </item>
  </channel>
</rss>