Fermat's factorization method

The factorization method of Fermat is an algorithm from the mathematical branch number theory. Calculate an odd composite number two divider and applies.

The factorization method of Fermat only has a good running time when the number to be decomposed can be represented as a product of approximately equal size factors. It also forms the basis of general factorization for large numbers that generally have a better life.

Pierre de Fermat described this today named after him factorization in 1643 in a letter, which was probably addressed to Mersenne or Frénicle de Bessy. In this letter, he demonstrated the method by calculating the prime factorization of 2,027,651,281. Some historians suggest that the method was, however, known earlier.

  • 2.1 Example with many iterations
  • 2.2 Example with a few iterations

Algorithm

Let ( odd) to factorize numbers. The factorization method of Fermat calculated successively the values

In this case, the smallest integer greater than or equal designated.

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

Due to the third binomial formula then:

This decomposition that is obtained by, for which the ratio ( with ) is the smallest.

The following Nassi- Shneiderman diagram shows the sequence of the algorithm, as it has already been applied by Fermat. In this case, the repeated squaring of the above description will be avoided. The individual values ​​are calculated to by the first binomial formula from their respective predecessors:

Note

By checking the last two digits of, one can exclude, in many cases, that is a perfect square. In a square number, there are only 22 options: 00, x1, x4, 25, y6 and x9, where x represents a straight and y is an odd number. You can exclude by checking the last two digits so many numbers that are square numbers. Fermat used this property of the square numbers.

Examples

Example with many iterations

One would like to determine factors of the number 1729. The square root of 1729 is about 41.6. The first number, for calculating, so the 42

One can now immediately calculate the two factors of:

A decomposition of 1729 is thus

Example with few iterations

The example of the number 290 377 you can see that there are numbers, in which the factorization method of Fermat very quickly calculates a decomposition. The square root of 290 377 is approximately 538.9. The nearest whole number is thus 539 It turns out that in the first step is a square number:

One can now immediately calculate the two factors of:

A decomposition of 290 377 is therefore

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

Operation

The factorization method of Fermat is now looking for two square numbers and which satisfy the equation. Due to the third binomial formula is then

And and are the desired divisor of. Fermat's method is doing exactly that and divider, which are closest to the root of.

This raises the question of whether two square numbers always exist and that satisfy the above equation. If this were not the case, the algorithm would go into an infinite loop. Hereinafter an odd composite number as the factorization of Fermat is provided. Then the product of two odd numbers and, thus are also

Integers. By a simple calculation using the binomial formula shows that is:

The number thus can always be represented as a difference of two square numbers.

Runtime Analysis

The procedure takes only a few iterations to a solution, if a number can be decomposed into two approximately equal factors. We can write the major factor in the form of a. If the value is much smaller than 1, is obtained for approximately the number of required iterations. In this case, the process is very much faster than the trial division.

However, if the factors are far apart, this method also needs a lot of iterations. In the worst case, where a prime number, this method requires many iterations.

Extension: factorizing a multiple

To avoid the bad maturity for numbers that the product of two approximately equal size factors are not, you can perform the factorization method for a multiple of the original number. The greatest common divisor between a and each of the calculated factors and then each provide a divisor of.

As an example, consider the number 1729, where the normal factorization requires 14 steps. The number can be decomposed after two iterations in the factors of 420 and 494. A divisor of 1729 can be calculated as the greatest common divisor:

With one has a factorization of the number 1729:

There now arises the problem of finding a suitable factor. Russell Sherman Lehman has developed in 1974 with the factorization of Lehman, a method that finds such. Thus, the running time is reduced to.

Factorization of Fermat primality test as

The factorization of the Fermat test may be used as a prime number, although it is not particularly efficient. Of runtime analysis is well known that the worst-case input to the algorithm is a number of the form ( this is a prime number ). In this case,

Can you now as an input of the algorithm any odd numbers and none of the numbers

A square number, it is a prime number.

325529
de