Do take a look at this also http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes#cite_note-7
Source code to list all prime numbers till number n #include<iostream> #include<algorithm> #define bool int using namespace std; int main(){ int n; cin>>n; int i,j; bool primeValues[1000]={0}; for(i=4;i<=n;i=i+2){ primeValues[i] = 1; } for(i=3;i*i<=n;i=i+2){ for(j=2;j<n/i;j++) primeValues[i*j] = 1; } for(i=2;i<n;i++){ if(primeValues[i] == 0) cout<< i<<" "; } } On Sun, Jul 24, 2011 at 11:51 AM, frank <abb...@gmail.com> wrote: > thanq u very much > > On Jul 23, 10:13 pm, arun kumar <kumar0...@gmail.com> wrote: > > hope this link will help youhttp:// > www.topcoder.com/tc?module=Static&d1=tutorials&d2=primalityTes... > > > > > > > > > > > > > > > > On Sat, Jul 23, 2011 at 10:39 PM, frank <abb...@gmail.com> wrote: > > > what is the efficient algorith to find the prime numbers or to check a > > > number prime or not ? > > > Helpful if the pseudo code provided. > > > > >>>>thank you > > > > > -- > > > You received this message because you are subscribed to the Google > Groups "Algorithm Geeks" group. > > > To post to this group, send email to algogeeks@googlegroups.com. > > > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > > > For more options, visit this group athttp:// > groups.google.com/group/algogeeks?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.