in reply to Re: Find prime number between 1 to 1000000
in thread Find prime number between 1 to 1000000
After testing 3 and 5, you can use the 2/4 trick (see Re^3: a close prime number) to skip all multiples of 3 leaving you with about 333 numbers to check. I agree that for a single number under 1 million a pure perl function can be created that does the job without resorting to anything more advanced. I have yet to find a simple (by my own subjective definition) method though that does better than testing 1/3 sqrt (N) numbers to determine if a number is prime. I guess it could be argued that using Math::Pari's primality test function is simple but I meant my own implementation.
Cheers - L~R
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Find prime number between 1 to 1000000
by tilly (Archbishop) on Jan 24, 2011 at 05:19 UTC | |
|
Re^3: Find prime number between 1 to 1000000
by JavaFan (Canon) on Jul 29, 2009 at 15:10 UTC |