Fermat Factorization Calculator

Enter an odd number to factor it with Fermat's method.

How to use

  1. Enter your values in the fields above.
  2. Press Calculate to see your result instantly.
  3. Use the Share button to copy a link to your result.

About this calculator

Fermat's factorization method exploits the fact that any odd integer N can be written as a difference of two squares, N = a² − b² = (a−b)(a+b). The algorithm starts at a = ⌈√N⌉ and increases a by 1 each step, checking whether a² − N is itself a perfect square (b²); the moment it is, N factors immediately into (a−b)(a+b). This calculator runs that loop and shows every step it took to find the factors.

The method converges in very few steps when N's two factors are close together — its main weakness is also its most important real-world use: cryptography students and security researchers use Fermat factorization to demonstrate why RSA moduli must be built from primes that are far apart, since primes chosen too close together make the modulus trivially breakable. It's also a standard exercise in number theory coursework for illustrating difference-of-squares reasoning.

Was this helpful?

Comments (0)

  • Be the first to comment.

Popular calculators

All Calculators