Integer Factorization ยท Number Theory ยท Cryptography

The General Number
Field Sieve

An interactive guide to the fastest known algorithm for factoring large integers. Learn the mathematics. Explore the code. Run live demonstrations.

Learn by Doing

๐Ÿ“–

Side-by-Side View

Read explanations alongside the actual Python source code that implements each concept.

โšก

Interactive Demos

Run real Python code in your browser. Experiment with different parameters and see results instantly.

๐ŸŽฏ

Step by Step

Follow the algorithm through each stage with worked examples and visualizations.

Not a toy โ€” a working factorization pipeline

Every stage mirrors the real algorithms behind GNFS. Polynomial selection, logarithmic sieving, sparse matrix algebra, and algebraic square roots โ€” all in readable Python.

from gnfs import gnfs_factor

# Factor a semiprime
n = 8051
factors = gnfs_factor(n)
print(f"{n} = {factors[0]} ร— {factors[1]}")
# โ†’ 8051 = 83 ร— 97