diffsquare-py

A Python implementation of Fermat’s Difference of Squares Factorization. This is the Python counterpart to the Rust crate diffsquare.

Features

Installation

Clone the repository:

git clone https://github.com/Abhrankan-Chakrabarti/diffsquare-py.git
cd diffsquare-py

Requires Python 3 and gmpy2:

pip install gmpy2

Usage

Factor a number via stdin:

echo 5959 | python factor.py

Or using the -n argument:

python factor.py -n 5959

Suppress verbose progress:

python factor.py -n 5959 --quiet

Set scientific notation precision (default is 30):

python factor.py -n 5959 -p 6

Set iteration print interval (default is 1,000,000):

python factor.py -n 5959 -i 100000

Start from a custom iteration offset:

python factor.py -n 5959 -s 1000