Subj : Re: Faster algorithm for prim numbers..!! To : comp.programming From : websnarf Date : Wed Sep 21 2005 07:49 pm Steve O'Hara-Smith wrote: > "Robert Bralic" wrote: > > I weated a simple program, he is compiled > > with gcc, and generates prim numbers, > > with fastes method that I find.He is based > > on divide with generated prim numbers... > > At end he gives time report on format: > > dd:hh:mi:sec... > > Precompile as gcc prim.c -o prim, and use > > him as "prim upper_bound",as example: > > "prim 1000".If anybody have some idea > > how to make algorithm fastes write to me...!! > > http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes > and > http://en.wikipedia.org/wiki/Sieve_of_Atkin That's fine if you want that set of primes between 1 and x. But if you want to check a random number for primality, or you want to nth prime, up to 32 bits, try this: http://www.pobox.com/~qed/primeat.zip -- Paul Hsieh http://www.pobox.com/~qed/ninja.html http://bstring.sf.net/ .