Fermat's factorization method Created 2026-10-14 Updated 2026-11-05
For a positive odd integer , Fermat's factorization method searches for integers satisfying . Start at and test successive values until is a perfect square . The difference of two squares then gives . For an even input, remove factors of two first.
The search always reaches at least the trivial factor pair , at . It is useful when a nontrivial factor pair is close: that pair is reached at , withA small difference between factor sizes therefore requires few trials. This is a different advantage from looking for a small prime factor by trial division.