Re: [algogeeks] Prime numbers
Hi Dod, Could you pls expalin what this algorithm is doing and from where you got it. Thanks Nitin On Wed, Aug 17, 2011 at 2:56 AM, Don wrote: > I wrote a program to print prime numbers, but it is not very fast. Can > someone help me figure out why? > > > #include > > /* This program implements a blindingly fast algorithm > to find prime numbers, using an elegant recursive method. */ > int _(int n, int m, int d, int t=0) > { >int r; >if (t) return d?1+_(n,m,d-1,d):n?_(n-1,m,m,n):0; >for(r=m!=n; d*(tr &= _(n,_(t,m,0,1),d-1)|!_(t,1,t); >return r*n; > } > > > /*-- > Print primes up to the requested value > */ > int main(int argc, char* argv[]) > { >for(int n = 2; n <= 1000; n++) >printf("%d is%s prime\n",n, _(n,1,n,0)?"":" not"); > >return 0; > } > > -- > 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.
Re: [algogeeks] Prime numbers
Can someone pls explain what dod's algorithm is doing? Dod, from where did you get this recursive algo? On Wed, Aug 17, 2011 at 8:45 AM, Dipankar Patro wrote: > Sieve's is the fastest in generating prime numbers. +1 to Sandeep and > Sanjay > > > On 17 August 2011 08:21, Sanjay Rajpal wrote: > >> Agree with Sandeep :) >> Try this link http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes. >> Hope it helps :) >> >> >> Sanjay Kumar >> B.Tech Final Year >> Department of Computer Engineering >> National Institute of Technology Kurukshetra >> Kurukshetra - 136119 >> Haryana, India >> >> >> On Tue, Aug 16, 2011 at 2:28 PM, sandeep pandey < >> sandeep.masum4...@gmail.com> wrote: >> >>> try to implement sieve. >>> it,s a well known algorithm to find out d prime frequently. >>> >>> -- >>> 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. >> > > > > -- > > ___ > > Please do not print this e-mail until urgent requirement. Go Green!! > Save Papers <=> Save Trees > > -- > 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.
Re: [algogeeks] Prime numbers
Sieve's is the fastest in generating prime numbers. +1 to Sandeep and Sanjay On 17 August 2011 08:21, Sanjay Rajpal wrote: > Agree with Sandeep :) > Try this link http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes. > Hope it helps :) > > > Sanjay Kumar > B.Tech Final Year > Department of Computer Engineering > National Institute of Technology Kurukshetra > Kurukshetra - 136119 > Haryana, India > > > On Tue, Aug 16, 2011 at 2:28 PM, sandeep pandey < > sandeep.masum4...@gmail.com> wrote: > >> try to implement sieve. >> it,s a well known algorithm to find out d prime frequently. >> >> -- >> 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. > -- ___ Please do not print this e-mail until urgent requirement. Go Green!! Save Papers <=> Save Trees -- 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.
Re: [algogeeks] Prime numbers
Agree with Sandeep :) Try this link http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes. Hope it helps :) Sanjay Kumar B.Tech Final Year Department of Computer Engineering National Institute of Technology Kurukshetra Kurukshetra - 136119 Haryana, India On Tue, Aug 16, 2011 at 2:28 PM, sandeep pandey wrote: > try to implement sieve. > it,s a well known algorithm to find out d prime frequently. > > -- > 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.
Re: [algogeeks] Prime numbers
try to implement sieve. it,s a well known algorithm to find out d prime frequently. -- 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.
[algogeeks] Prime numbers
I wrote a program to print prime numbers, but it is not very fast. Can someone help me figure out why? #include /* This program implements a blindingly fast algorithm to find prime numbers, using an elegant recursive method. */ int _(int n, int m, int d, int t=0) { int r; if (t) return d?1+_(n,m,d-1,d):n?_(n-1,m,m,n):0; for(r=m!=n; d*(thttp://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Prime Numbers
hope this link will help you http://www.topcoder.com/tc?module=Static&d1=tutorials&d2=primalityTesting On Sat, Jul 23, 2011 at 10:39 PM, frank 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 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.
[algogeeks] Prime Numbers
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 at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Prime Numbers
Hi Its an easy one but still I am looking for the most efficient approach. Find first 1 million prime numbers. -- Siddharth Srivastava When you have learned to snatch the error code from the trap frame, it will be time for you to leave. -- 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.