Fermat's factorization method

from Wikipedia, the free encyclopedia

The factorization method of Fermat is an algorithm from the mathematical branch number theory . He calculates two divisors and for an odd composite number , for which applies.

Fermat's factorization method only has a good runtime if the number to be broken down can be represented as a product of factors of approximately equal size. It also forms the basis of general factoring methods for large numbers, which usually have a better running time.

Pierre de Fermat described this factoring method, which is named after him today, in a letter in 1643 , which was probably addressed to Mersenne or Frénicle de Bessy . In that letter, he demonstrated the process by computing the prime factorization of 2,027,651,281. However, some historians suspect that the method was known earlier.

algorithm

Let be the odd number to be factored. Fermat's factoring method calculates the values ​​one after the other

The smallest whole number denotes greater than or equal to .

This continues until one of these values ​​is a square number :

Based on the third binomial formula, the following applies

This gives the decomposition of for which the ratio is (with ) the smallest.

The following Nassi-Shneiderman diagram shows the sequence of the algorithm as it was already used by Fermat. The repeated squaring of the above description is avoided. The individual values ​​are calculated using the first binomial formula from their respective predecessor:

Calculate
Calculate
as long as no square number
Calculate
Calculate
Calculate

annotation

In many cases, by checking the last two digits of , one can rule out that is a square number. With a square number there are only 22 possibilities: 00, x1, x4, 25, y6 and x9, where x stands for an even and y for an odd number. With many numbers you can therefore rule out that they are square numbers by checking the last two digits. Fermat also used this property of the square numbers. This also works with other quadratic remainders , such as powers of two, which can easily be checked on a classic computer architecture. This idea can be generalized by examining not only the squares but the quadratic equation in two variables with respect to their residues:

Because of the property there can be maximally possible residues if and are coprime. By combining the remainder classes with respect to different prime numbers (or small prime powers), the solutions for each remainder class used can be almost halved.

Examples

Example with many iterations

One would like to determine factors of the number 1729. The root of 1729 is about 41.6. So the first number to calculate for is 42.

42 35 85
43 120 87
44 207 89
45 296 91
46 387 93
47 480 95
48 575 97
49 672 99
50 771 101
51 872 103
52 975 105
53 1080 107
54 1187 109
55 1296 = 36 2

You can now immediately calculate the two factors of :

A decomposition from 1729 reads:

Example with a few iterations

The example of the number 290377 shows that there are numbers for which Fermat's factorization method calculates a decomposition very quickly. The square root of 290377 is approximately 538.9. The next whole number is thus 539. It turns out that in the first step there is already a square number:

You can now immediately calculate the two factors of :

A decomposition of 290377 is thus

Neither are nor prime numbers. But you can apply the algorithm again on 551 and 527 to get the full prime factorization.

Graphic example

All integer dividers can be represented as points in a dividing surface. The -axis shows the divisor values, the -axis corresponds to an integer number line (for better comprehensibility in the example the - and -axis are scaled in a ratio of 1 to 16).

The dividing points in a dividing surface have u. a. following properties:

  • All dividing points of the dividing surface can be assigned to a negative parabola of the shape .
  • All complementary divisor pairs of a number are on a common parabola.
  • The addition of two complementary divisors of a number yields the coefficient of the common negative parabola.

Example:

Fermat's factorization in the divisor plane

The complementary divisor pairs of are the trivial divisors and the non-trivial divisors .

The intersections of parabolas form with the parallel to the axis thus providing divider candidates. Shifting the parabola supplies either the non-trivial or, in the very last step, the trivial divisors of a number.

The first negative parabola with a vertex value greater is identified ( ). After moving it several times, the divisors and are found with the parabola . Is the vertex of this parabola .

The number can thus be represented as the difference between the squares . The non-trivial factors can be calculated using and .

Since parabolas of the form only provide complementary divisors to even numbers, they are not taken into account in Fermat's method.

functionality

Fermat's factorization method looks for two squares and that satisfy the equation . Based on the 3rd binomial formula , then

and and are the divisors of . Fermat's method finds precisely those divisors and that are closest to the root of .

The question arises whether there are always two square numbers and that satisfy the above equation. If this were not the case, the algorithm would get into an infinite loop . In the following, an odd composite number is assumed, as in Fermat's factoring method. Then is the product of two odd numbers and and so are

and

whole numbers. A simple calculation using the binomial formulas shows that :

The number can therefore always be represented as the difference between two square numbers.

Runtime analysis

The method will find a solution in a few iterations if a number can be broken down into two approximately equal factors. We can write the larger factor in the form with one . If the value is much smaller than 1, the number of iterations required is approximate . In this case, the procedure is much faster than the trial division.

However, if the factors are far apart, this method also needs a large number of iterations. In the worst case at , where is a prime number, this method takes many iterations.

Extension: Factoring a multiple

In order to avoid the bad running time for numbers that are not the product of two approximately equal factors, the factoring method can be carried out for a multiple of the original number . The greatest common divisors between and each of the calculated factors and of then each provide a divisor of .

As an example, consider number 1729, which the normal factoring method takes 14 steps. The number can be broken down into factors 420 and 494 after just two iterations. A divisor of 1729 can be calculated as the greatest common divisor:

With one has a factorization of the number 1729:

The problem now arises of finding a suitable factor . Russell Sherman Lehman has 1,974 to the factorization of Lehman developed a method that such place. This shortens the running time to .

Fermat's factorization method as a prime number test

Fermat's factorization method can be used as a primality test , although it is not particularly efficient. From the runtime analysis it is known that the most unfavorable input for the algorithm is a number of the form ( is a prime number). In this case it is

If one now allows any odd numbers as input to the algorithm and none of the numbers is

a square number, so is a prime number.

literature

Web links

Individual evidence

  1. ^ Leonard E. Dickson : History of the Theory of Numbers. Volume 1. Divisibility and Primality. Dover Publications, 2005, ISBN 0-486-44232-2 , p. 357.
  2. ^ Richard Crandall , Carl Pomerance : Prime Numbers. A Computational Perspective. 2nd Edition. Springer-Verlag, New York, 2005, ISBN 0-387-25282-7 , pp. 191-192.