Monday, May 27, 2013

Prime Number

Prime number is a number which is  divisor by 1 and itself. It is a number that can't divisor except 1 or itself. The first few prime numbers are 2, 3, 5, 7, 11, 13, 17, 19, 23, and 29.
On the other hand, A prime number is a whole number greater than 1, whose only two whole-number factors are 1 and itself..
Suppose n is a whole number, and we want to test it to see if it is prime.   First, we take the square root (or the 1/2 power) of n; then we round this number up to the next highest whole number.  Call the result m.  We must find all of the following quotients:
qm = n / m
q(m-1) = n / (m-1)
q(m-2) = n / (m-2)
q(m-3) = n / (m-3)
. . .
q3 = n / 3
q2 = n / 2
The number n is prime if and only if none of the q's, as derived above, are whole numbers.

Prime Number Program 

No comments:

Post a Comment