Changes

Jump to navigation Jump to search
1 byte removed ,  19:56, March 18, 2007
Line 18: Line 18:  
To determine whether a number is prime, you can use the trial division method, provided the number you are testing is not too large.  Let ''N'' be the number being tested and ''s'' be its square root.  Divide ''N'' by each number in the prime table, beginning with 2.  If there is no remainder, stop--N is composite.  Otherwise, test again with the next largest prime in the table.  If the next largest prime is greaster than ''s'', stop--''N'' is prime.  
 
To determine whether a number is prime, you can use the trial division method, provided the number you are testing is not too large.  Let ''N'' be the number being tested and ''s'' be its square root.  Divide ''N'' by each number in the prime table, beginning with 2.  If there is no remainder, stop--N is composite.  Otherwise, test again with the next largest prime in the table.  If the next largest prime is greaster than ''s'', stop--''N'' is prime.  
   −
For larger values of ''N'', a method based on Fermat's theorem can be used, though it usually requires a computer.  Start with the number 1, and double it ''N-1'' times.  Divide this number by ''N'', keeping only the remainder.  If the remainder is greater than 1, ''N'' is composite.  Unfortunately, the converse is not true--if the remainder is 1, ''N'' is ''probably'' prime, but not necessarily.  Algorithms which improve on this method exists, and primality testing is today an active subject of mathematical research.
+
For larger values of ''N'', a method based on Fermat's theorem can be used, though it usually requires a computer.  Start with the number 1, and double it ''N-1'' times.  Divide this number by ''N'', keeping only the remainder.  If the remainder is greater than 1, ''N'' is composite.  Unfortunately, the converse is not true--if the remainder is 1, ''N'' is ''probably'' prime, but not necessarily.  Algorithms which improve on this method exist, and primality testing is today an active subject of mathematical research.
139

edits

Navigation menu