Fermat method
The Fermat method is a factorization algorithm for odd integers that tries to represent them as the difference of two square numbers.
Call the Fermat method algorithm with an integer .
-
1.
Initialize the iterator and test cap at .
-
2.
Compute .
-
3.
Test if is an integer. If it is, break out of subroutine and return .
-
4.
Increment iterator once. If , go to step 2.
-
5.
Return .
For example, . The square root is approximately 15, so that’s what we set our iterator’s initial state to. The test cap is 39.
At , we find that , clearly an integer.
Then, and . By multiplication, we verify that , indeed. By trial division, this would have taken 15 test divisions.
However, there are integers for which trial division performs much better than the Fermat method, such as numbers of the form where is an odd prime greater than 3.
References
- 1 R. Crandall & C. Pomerance, Prime Numbers: A Computational Perspective, Springer, NY, 2001: 5.1
Title | Fermat method |
---|---|
Canonical name | FermatMethod |
Date of creation | 2013-03-22 16:39:03 |
Last modified on | 2013-03-22 16:39:03 |
Owner | PrimeFan (13766) |
Last modified by | PrimeFan (13766) |
Numerical id | 6 |
Author | PrimeFan (13766) |
Entry type | Algorithm |
Classification | msc 11A41 |
Synonym | Fermat’s method |
Synonym | Fermat factorization method |
Synonym | Fermat’s factorization method |