Anda di halaman 1dari 10

An algorithm for extracting primes

By Samuel Bonaya Buya

Ngao girls’ secondary school

December 2017
Declaration
The article entitled “An algorithm for extracting primes” is my own original work and every effort has
been made to acknowledge any work cited by means of proper referencing.
Abstract
In this research a method of extracting primes from even numbers is proposed. The method is based on
the assumption that a composite odd prime number can always be factorized into two odd numbers
with each of the prime numbers having a value of greater than one.

Introduction
Prime numbers are of fundamental importance in mathematics and particularly number theory. In
researches involving prime numbers a lot of time has been spent in the search for those properties that
can efficiently determine if a number is prime. A correct, reliable and sufficient primality test is one that
can separate composite odd numbers from odd prime numbers. Fermat’s little theorem fails do so.

Many primality and compositeness tests have been proposed and used in mathematics. A primality test
is an algorithm of determining whether an input number is a prime number. A compositeness test is an
algorithm in which is an input number is composite.

When a compositeness test is properly defined and simplified it can be used to extract both composite
odd numbers and odd prime numbers.

We know the product of an odd number and an odd number is an odd number. This means at minimum
a composite odd number is a product of two odd numbers each greater than one. This mathematical
truth will be used to come up with a procedure for extracting prime numbers.

Method

x ³1 2x +1 2 y +1
Consider two natural numbers, x and y such that and y>1. Two odd numbers, and
can be formed from these natural numbers. The product of these two odd numbers is a composite odd
number given by:

Oc = (2 x + 1)(2 y + 1)
1

Equation one can be expanded and simplified to:


4 xy + 2( x + y ) = Oc - 1 = e
2

e
Here, is an even number.

Expanding and simplifying equation 2:

e
-x
e - 2x 2
y= =
4x + 2 2x + 1
3

Equation 3 can be viewed as a Diophantine relationship between e, x and y.

e +1
The Diophantine relationship above holds if ( ) is a composite odd number but does not hold if (
e +1
) is a prime number. This is to say for a given even number (e), if x and y have positive integral
e
2
values then (e+1) is a composite number otherwise it is a prime number. In equation 3 if ( ) is even
then select an odd value of x to make the numerator value odd (notice the denominator value is odd). If
e
2
( ) is odd select an even value of x to make the numerator value odd.

The Upper bound value of x is obtained when y is 1 and is given by:

e-2
xub =
6
4

e e
2 2
 The lower bound value of x is 2 if ( ) is odd and 1 if ( ) is even.
 The interval between successive test values of x is 2. The test values are the values used to solve
the Diophantine equation 3 above. Test values may be even or odd but cannot be
simultaneously odd and even for a given even number. The test values are odd if of half the
selected even results to another even number. The test values are on the other hand is even if
half of the selected even number results to an odd number.
e
2
 If ( ) is odd then the interval of x is given by:

e-2
2£ x£
6
5

The test values of x extracted from the interval 5 above are even

e
2
 If ( ) is even then the interval of x is given by:

e-2
1£ x £
6
6

 In general the family of curves of equation cut the x and y axes at all the positive integer values
(see figures 1 and 2)

The test values of x extracted from the interval 6 are odd.

If one of the above boundary values form a solution of the Diophantine equation 3 then (e+1) is a
composite odd number. If all the values of x in the given interval do not satisfy the Diophantine equation
3 above then (e+1) is an odd prime number.

Example 1

e +1 = 9 ® e = 8
The odd number ( ), the upper bound value of x (from 4) is 1 while the lower bound
value is 1 Thus the two boundary values coincide. The test value of x is therefore equal to 1. On
substituting this test value in equation 3 we get y = 1. This implies than 9 is a composite odd number.

Example 2

4
e + 1 = 11 ® e = 10 3
The odd number ( ), the upper bound value of x (from 4) is while the lower
boundary value is 2, since half the even number gives an odd number. Since the lower bound value is
less than the calculated upper bound value then the odd number that has no test value is an odd prime
number.

Example3
17
e + 1 = 37 ® e = 36 3
The odd number ( ), the upper bound value of x (from 4) is while the lower
(1,3)
bound value is 1, since half the even number gives another even number. The test values of x are .

(17 ,15 )
3 7
On substituting these test values we obtain the values of y as . These values of y are
fractional. Thus the odd number is an odd prime number.

Figure 1: Odd primes don’t have solution to the Diophantine equation 2. They
Figure 2: composite prime have integer solution of the Diophantine equation 3 labeled on the graph.

Thus to determine the primality of a given odd number:


 Determine the interval of x
 Identify the test values of x
 Use the test values of x to evaluate y
 If for a given set of test values an integral value of y is obtained then the odd number is
composite, otherwise it is a prime number.

With these results we can come up with a simple algorithm for extracting prime numbers.

Algorithm for extracting primes:

Step1: Start

e, x1 , x2 ...xn , y1 , y2 ,... yn
Step2: Declare the variables

Step 3: Calculate y

e - 2 x1
y1 ¬
4 x1 + 2

e - 2 x2
y2 ¬
4 x2 + 2

.
.
.
e - 2 xm
yn ¬
4 xn + 2

y <1
Step 4: If

e +1
Display is a prime number

Step 5: Stop

The above algorithm can be improved bearing in mind all the issues discussed above.
Thus the problem of extracting primes from a set of natural numbers is easily solvable and easily
verifiable.

The AKS primality test placed PRIMES in P. The above method of extracting PRIMES makes them to be P-
complete. An easy algorithm exists for verifying primality of an odd number, which NP since they are
easily checkable in polynomial time in which case for Primes P=NP

Conclusion and recommendation


An easy method for extracting primes form a given set of odd prime numbers has been found. Given an
even number the odd number immediately after it can be established to be composite or prime using an
algebraic equation which can be used to simultaneously solve the problem in polynomial time and verify
the solution in polynomial time. Thus primes are both P and NP complete.

Works Cited
Lehman, D. J. (May 1982). On Primality tests. SIAM Journal on Computing, 374-375.

Manindra Agrawal, N. K. (Sep., 2004). Primes in P. Annals of Mathematics vol. 160, No.2, 781-793.
Shanks, W. A. (1982). Strong Primality tests that are not sufficient. Math.Comp 39, 255-300.

Anda mungkin juga menyukai