fermat_factor


fermat_factor, an Octave code which uses Fermat's factorization method to decompose an integer N into the product of two factors, N = A^2-B^2 = (A+B)*(A-B).

The algorithm seeks to write N = A^2 - B^2 = ( A + B ) * ( A - B ).

Licensing:

The information on this web page is distributed under the MIT license.

Languages:

fermat_factor is available in a C version and a C++ version and a Fortran90 version and a MATLAB version and an Octave version and a Python version.

Related Data and Programs:

fermat_factor_test

is_prime, an Octave code which determines if a given integer n is prime, using various versions of the sieve of Eratosthenes.

prime_factors, an Octave code which returns a list of the prime factors of an integer.

prime_fermat, an Octave code which applies Fermat's primality test to an integer n, which always correctly identifies primes, but sometimes also accepts nonprimes. Nonetheless, the test is useful for weeding out most nonprimes. The accuracy of the test can be improved by running it for several bases.

prime_pi, an Octave code which evaluates Pi(n), the number of primes less than or equal to an integer n.

prime_plot, an Octave code which displays a box plot of the prime and composite numbers.

Reference:

  1. Manon Bischoff,
    This more than 380-year-old trick can crack some modern encryption,
    Spektrum der Wissenschaft,
    09 April 2025.

Source Code:


Last revised on 09 April 2025.