[algogeeks] Re: Primality testing

2013-04-15 Thread Don
For numbers larger than what can be stored in your computer's native integer types, you should use an extended precision math library. NTL is one such option. It provides a type called ZZ which supports integer operations where the size is limited only by your computer's memory and speed. Don On

[algogeeks] Re: Primality testing

2013-04-15 Thread Don
Trial division is fine for small numbers, perhaps up to 10 digits. But think for a moment about what that would take for a 1000 digit number. The square root of such a number is 500 digits. There are about 10^496 primes smaller than 10^500. If you have a billion computers each checking a billion of