Prime Home Primer on Primes In Search of Primes Sieve of Eratosthenes Files References Table of Contents

A Primer on Primes

Introduction : Prime numbers are the basis of many modern enciphering methods. Primes are now the basis of entire fields of applied mathematics. We now have governments trying to define illegal use of prime numbers. This makes prime numbers exciting, if not interesting. The simplicity of prime numbers also appeals to the problem solver. Unfortunately most information sources on prime numbers do not address the basics of prime numbers.

History : A long time ago in a land far away... (Greece about 600 BC) Many mathematicians were discovering the fundamentals of number theory, geometry, and trigonometry. Philolaus is credited with formalizing all natural numbers into composite or prime categories. About 400 years later, Eratosthenes became famous for two discoveries. He calculated the perimeter of the earth to within 5% of the actual value. He also developed the Sieve of Eratosthenes, a fast method for screening prime numbers.

Primes Defined : Natural numbers, integers, and whole numbers are the same. All of these describe numbers without fractional or decimal parts. Two, three , five, and 4356 are all natural numbers. The old Greeks did not recognize zero or one, but they also are natural numbers. 3.1415, 1.234, and 1/3 are not natural numbers, since they have fractional or decimal parts. For the rest of this paper, these two types of numbers will be split into two groups, Integer numbers and Real numbers. Integers are natural numbers, and real numbers are everything not Integer.

If you remember back to elementary school, you may remember fractions. You may remember factoring of Integers. You probably don't remember it with any fondness. In the table below, we put a series of numbers and list the factors. Table 2 contains factors of numbers to 255.

Table 1 - Numbers and Factors
Integer Factor Integer Factor Integer Factor
1 1 11 11 21 3·7
2 2 12 2·2·3 22 2·11
3 3 13 13 23 23
4 2·2 14 2·7 24 2·2·2·3
5 5 15 3·5 25 5·5
6 2·3 16 2·2·2·2 26 2·13
7 7 17 17 27 3·3·3
8 2·2·2 18 2·3·3 28 2·2·7
9 3·3 19 19 29 29
10 2·5 20 2·2·5 30 2·2·5

If we examine the information in this table, some things can be learned. Everyone of these numbers are either a factorable or not factorable (duh). If the number is factorable, all of the factors are non-factorable numbers. The non-factorable numbers are prime numbers. Prime numbers are defined as numbers only factorable by one and themselves. All factorable (non-prime) numbers are called composite numbers.

The reason most of us disliked factoring is the lack of a simple method of finding the factors, or primeness. There are a number of 'tricks' used to find simple factors. Some of these are listed below:

  • All even numbers (numbers ending with 0,2,4,6,8) are factorable by 2
  • All numbers ending with 0 and 5 are factorable by 5
  • If the sum of the digits (of the number) are factorable by 3, the original number is also factorable by 3.

There are also methods 7, 11 and 13, but are progressively more complex. There methods are different for each prime factor, and increasingly more difficult. These methods are also not computer appropriate. These methods are appropriate for manual factoring only.

Algebra of Primes: In the next sections methods of factoring for small primes will be explained. In order to understand the methods, a few fundamental rules need to be defined.

Factors of Sums: If we have the following conditions :

A = B + C
B = b·d
C = c·d

where d is a factor of both B and C, and therefore it is also a factor of A.

Example : If we add a number factorable by 7, 42 to another number factorable by 7 say 70, the result is 112, which factors to 2·2·2·2·7. As you can see 112 does have 7 as a factor.

Factors of Products : If we a product of A and some factor B:

C = A·B
C = c·d

If C has some factor d, and d is not a factor of B, A is then factorable by d.

Example : If we multiply 21 by 5 with the result of 105, and 105 is factorable by 7, then 21 is factorable by 7, since 5 is not factorable by 7.

Factoring 3 : The finding factors of 3 is sometimes used, but rarely proven. Finding if a number is factorable by three is done as follows
  1. If the number has 2 or more digits, add the digits.
  2. If the result has 2 or more digits repeat step 1
  3. If the result has 1 digit and is factorable by three (i.e. 3, 6, or 9) the original number is factorable by 3.

Example 1

  • Start with 123456.
  • Add the digits : Sum 1 = 1+2+3+4+5+6 = 21
  • Add the digits of Sum 1 : Sum 2 = 2+1 = 3
  • The result is 3, which is factorable by 3, therefore 123456 is factorable by 3.

Example 2

  • Start with 987654321
  • Add the digits : Sum 1 = 9+8+7+6+5+4+3+2+1 = 45
  • Add the digits of Sum 1 : Sum 2 = 4+5 = 9
  • The result is 9, which is factorable by 3, therefore 987654321 is factorable by 3.

Some of you may be wondering how this works. First we need to step back and look at how we can algabraically work with prime numbers. This is also defined in the section above on Algebra of Primes.

If A = B·d + C·d, where d is some factor, A is factorable by d.

If we represent some number Q as a series of sums where dx are the digit values we have:

Q = d1 + d2·10 + d3·100 + d4·1000....

and according to the associative rule we can define Q as

Q = term1 + term2

If both term1 and term2 are factorable by a given number A, the number Q is factorable by the same number A.

By re-arranging the series of sums in the equation above we have:

Q = d1 + d2 + d3 + d2·9 + d3·99 + d4·999

Q = (d1 + d2 + d3) + (d2·9 + d3·99 + d4·999)

Examination of the second set of terms reveals that it is factorable by 9 for all possible numbers of Q, and therefore factorable by 3. If the first set of terms are factorable by 3, Q is factorable by 3.

This is not a mathematically rigorous proof, but an adequate explanation of the algorithm.

Factoring by 11: If we represent the number we are factoring :

Q = d1 + 10·Dn

where d1 represents the lowest digit and Dn represents all of the digits above d1. This equation can be algebraically rearranged :

Q = d1 - 1·Dn + 11·Dn

-Q = ( Dn -d1 ) - (11·Dn)

In terms of factoring the equations above are equivalent, since the only difference is an additional factor of -1 in the -Q equation. This representation once again results in two terms, the second of which is clearly factorable by 11. The first term can be recursively entered into the same function until it is clearly factorable / non-factorable by 11. The method is best summarized as:

  1. For any number Q, subtract the lowest digit of Q from the digits above the lowest digit.
  2. If the result is still large, repeat step1.
  3. If the result is factorable by 11, Q is factorable by 11. If the result is not factorable by 11, Q is not factorable by 11.

Example 1:

  • Q = 108636
  • In the first step we take the lower digit (6) and subtract it from the upper digits (10863), and get Q1 = 10857
  • Since Q1 is still large, we repeat Q2 = 1085 - 7 = 1078
  • And again, Q3 = 107-8 = 99
  • 99 is clearly factorable by 11 (11,22,33,44,55,66,77,88,99) therefore 108636 is factorable by 11

Example 2:

  • Q = 99999
  • In the first step we take the lower digit (9) and subtract it from the upper digits (9999), and get Q1 = 9990
  • Since Q1 is still large, we repeat Q2 = 999 - 0 = 999
  • And again, Q3 = 99 - 9 = 90
  • 90 is clearly not factorable by 11 (11,22,33,44,55,66,77,88,99) therefore 99999 is not factorable by 11

Factoring by 7: This is similar to the factoring by 11 exercise above.

If we represent the number we are factoring :

Q = d1 + 10·Dn

where d1 represents the lowest digit and Dn represents all of the digits above d1. This equation can be algebraically rearranged :

2·Q = 2·d1 - 1·Dn + 21·Dn

-2·Q = ( Dn -2·d1 ) - (21·Dn)

In terms of factoring the equations above are equivalent, since the only difference is an additional factor of -2 in the -Q equation. This representation once again results in two terms, the second of which is clearly factorable by 7. The first term can be recursively entered into the same function until it is clearly factorable / non-factorable by 7. The method is best summarized as:

  1. For any number Q, subtract twice the lowest digit of Q from the digits above the lowest digit.
  2. If the result is still large, repeat step1.
  3. If the result is factorable by 7, Q is factorable by 7. If the result is not factorable by 7, Q is not factorable by 7.

Example 1:

  • Q = 123456
  • In the first step we take twice the lower digit (6) and subtract it from the upper digits (12345), and get Q1 = 12345 - 2·6 = 12333
  • Since Q1 is still large, we repeat Q2 = 1233 - 2·3 = 1227
  • And again, Q3 = 122 - 2·7 = 108
  • With a little effort we can determine that 108 is not factorable by 7, therefore 123456 is not factorable by 7

Example 2:

  • Q = 86415
  • In the first step we take twice the lower digit (5) and subtract it from the upper digits (8641), and get Q1 = 8641 - 2·5 = 8631
  • Since Q1 is still large, we repeat Q2 = 863 - 2·1 = 861
  • And again, Q3 = 86 - 2·1 = 84
  • With a little effort we can determine that 84 is factorable by 7, therefore 86415 is factorable by 7

Factoring by 13: This is similar to the factoring by 11 exercise above. This is third example of this method. After this you should be able to apply this method to any factor of reasonable size.

If we represent the number we are factoring :

Q = d1 + 10·Dn

where d1 represents the lowest digit and Dn represents all of the digits above d1. This equation can be algebraically rearranged :

4·Q = 4·d1 + 1·Dn + 39·Dn

4·Q = ( Dn +4·d1 ) + (39·Dn)

In terms of factoring the equations above are equivalent, since the only difference is an additional factor of 4 in the second Q equation. This representation once again results in two terms, the second of which is clearly factorable by 13. The first term can be recursively entered into the same function until it is clearly factorable / non-factorable by 13. The method is best summarized as:

  1. For any number Q, subtract four times the lowest digit of Q from the digits above the lowest digit.
  2. If the result is still large, repeat step1.
  3. If the result is factorable by 13, Q is factorable by 13. If the result is not factorable by 13, Q is not factorable by 13.

Example 1:

  • Q = 97531
  • In the first step we take the four times the lower digit (1) and add it to the upper digits (9753), and get Q1 = 9753 + 4·1 = 9757
  • Since Q1 is still large, we repeat Q2 = 975 + 4·9 = 1011
  • And again, Q3 = 101 + 4·1 = 105
  • And again, Q4 = 10 + 4·5 = 30
  • 30 is clearly not factorable by 13, therefore 97531 is not factorable by 13

Example 2:

  • Q = 56173
  • In the first step we take the four times the lower digit (3) and add it to the upper digits (9753), and get Q1 = 5617 + 4·3 = 5629
  • Since Q1 is still large, we repeat Q2 = 562 + 4·9 = 598
  • And again, Q3 = 59 + 4·8 = 91
  • And Again Q4 = 9 + 4·1 = 13
  • 13 is clearly not factorable by 13, therefore 56173 is not factorable by 13

Summary : We can summarize this topic to the following:
  • All integers are either prime or composite (factorable)
  • If a number fails all factoring tests, it is prime.
  • All even integers are factorable by 2
  • All integers ending with 0 or 5 are factorable by 5
  • There are iterative methods for factor testing by 3, 5, 7, and 13. This method can also be extended to other factors.

modified : 06-Nov-1998 02:46 PM
author : Tom Wolf
https://members.tripod.com/~tomwwolf
email : tomwwolf@rocketmail.com
Counter :