Mail Archives: djgpp/1997/11/26/20:28:29
On Sun, 26 Oct 1997, Peter Palotas wrote:
> I was just wondering if anyone knew of a nice fast mehtod of finding prime
> numbers? ex. finding all 5-number prime numbers, (10000-99999)?
>
> I know this is off topic, but I don't have newsgroup access, and this is
> the only place I know of where to find programmers.
There is a method known as Rabin's test for primality. It does not
guarantee that the number tested is prime, however, there is a very large
chance that it is so.
Select 100 numbers randomly from 1.. N (where N is the number to be tested
for primality). See if N is factorable by any of the 100 numbers. If not,
then it is prime.
This might sound really stupid, but it actually works (most of the time).
I got the idea from a book, "Out of their minds" which follows the
discoveries of some great computer scientists (Djikstra, Rabin, the fellow
who designed the Connection Machine, et al).
-------------------------------------------------------------------
Orlando Alcantara Andico Email: orly AT dilnet DOT upd DOT edu DOT ph
ICBM: 14 30 00 N 120 59 00 E POTS: (+632) 932-2385
"If I shed a tear I won't cage it, I won't fear love, and if I feel
a rage I won't deny it, I won't fear love." - Sarah Mclachlan
- Raw text -