Tuesday, December 22, 2015

In my convoluted way........u eliminate more than half the entire number line right off the bat.......by taking out all multiples of two and 5..........half of all positive numbers are even............take out all the 5s also...........gone is over 50%................


To find individual small primes trial division works well.  To test n for primality (to see if it is prime) just divide by all of the primes less than the square root of n.  For example, to show is 211 is prime, we just divide by 2, 3, 5, 7, 11, and 13. (Pseudocode [Bressoud89, pp 21-22], PASCAL [Riesel94, pp 7-8].)  Sometimes the form of the number n makes this especially effective (for examples, Mersenne divisors have a special form).
Rather than divide by just the primes, it is sometimes more practical to divide by 2, 3 and 5; and then by all the numbers congruent to 1, 7, 11, 13, 17, 19, 23, and 29 modulo 30--again stopping when you reach the square root.  This type of factorization is sometimes called wheel factorization.  It requires more divisions (because some of the divisors will be composite), but does not require us to have a list of primes available.
Suppose n has twenty-five or more digits, then it is impractical to divide by the primes less than its square root.  If n has two hundred digits, then trial division is impossible--so we need much faster tests.  We discuss several such tests below.

No comments:

Post a Comment